#
# @(#)dotsh.pl 03/19/94
#
# This library is no longer being maintained, and is included for backward
# compatibility with Perl 4 programs which may require it.
#
# In particular, this should not be used as an example of modern Perl
# programming techniques.
#
#
# Author: Charles Collins
#
# Description:
# This routine takes a shell script and 'dots' it into the current perl
# environment. This makes it possible to use existing system scripts
# to alter environment variables on the fly.
#
# Usage:
# &dotsh ('ShellScript', 'DependentVariable(s)');
#
# where
#
# 'ShellScript' is the full name of the shell script to be dotted
#
# 'DependentVariable(s)' is an optional list of shell variables in the
# form VARIABLE=VALUE,VARIABLE=VALUE,... that 'ShellScript' is
# dependent upon. These variables MUST be defined using shell syntax.
#
# Example:
#
sub dotsh {
local(@sh) = @_;
local(*dotsh);
undef *dotsh;
chop($_ = <_SH_ENV>);
close (_SH_ENV);
if (!$shell) {
$shell = "$ENV{'SHELL'} -c";
} else {
}
}
if (length($vars) > 0) {
open (_SH_ENV, "$shell \"$vars && . $command $args && set \" |") || die;
} else {
open (_SH_ENV, "$shell \". $command $args && set \" |") || die;
}
while (<_SH_ENV>) {
chop;
m/^([^=]*)=(.*)/s;
}
close (_SH_ENV);
}
eval $tmp;
}
1;