dotsh.pl revision 1
1N/A# This library is no longer being maintained, and is included for backward 1N/A# compatibility with Perl 4 programs which may require it. 1N/A# In particular, this should not be used as an example of modern Perl 1N/A# programming techniques. 1N/A# Author: Charles Collins 1N/A# This routine takes a shell script and 'dots' it into the current perl 1N/A# environment. This makes it possible to use existing system scripts 1N/A# to alter environment variables on the fly. 1N/A# &dotsh ('ShellScript', 'DependentVariable(s)'); 1N/A# 'ShellScript' is the full name of the shell script to be dotted 1N/A# 'DependentVariable(s)' is an optional list of shell variables in the 1N/A# form VARIABLE=VALUE,VARIABLE=VALUE,... that 'ShellScript' is 1N/A# dependent upon. These variables MUST be defined using shell syntax. 1N/A open (
_SH_ENV,
"$command") ||
die "Could not open $dotsh!\n";
1N/A $
shell =
"$1 -c" if ($_ =~ /^\
#\!\s*(\S+(\/sh|\/ksh|\/zsh|\/csh))\s*$/); 1N/A print "SHELL not recognized!\nUsing /bin/sh...\n";
1N/A open (
_SH_ENV,
"$shell \"$vars && . $command $args && set \" |") ||
die;
1N/A open (
_SH_ENV,
"$shell \". $command $args && set \" |") ||
die;
1N/A $
tmp .=
"\$$key = \$ENV{'$key'};" if $
key =~ /^[A-
Za-z]\w*$/;