1 warn "Legacy library @{[(caller(0))[6]]} will be removed from the Perl core distribution in the next major release. Please install it from the CPAN distribution Perl4::CoreLibs. It is being used at @{[(caller)[1]]}, line @{[(caller)[2]]}.\n";
4 # @(#)dotsh.pl 03/19/94
6 # This library is no longer being maintained, and is included for backward
7 # compatibility with Perl 4 programs which may require it.
8 # This legacy library is deprecated and will be removed in a future
11 # In particular, this should not be used as an example of modern Perl
12 # programming techniques.
14 # Author: Charles Collins
17 # This routine takes a shell script and 'dots' it into the current perl
18 # environment. This makes it possible to use existing system scripts
19 # to alter environment variables on the fly.
22 # &dotsh ('ShellScript', 'DependentVariable(s)');
26 # 'ShellScript' is the full name of the shell script to be dotted
28 # 'DependentVariable(s)' is an optional list of shell variables in the
29 # form VARIABLE=VALUE,VARIABLE=VALUE,... that 'ShellScript' is
30 # dependent upon. These variables MUST be defined using shell syntax.
33 # &dotsh ('/foo/bar', 'arg1');
34 # &dotsh ('/foo/bar');
35 # &dotsh ('/foo/bar arg1 ... argN');
40 local($tmp,$key,$shell,$command,$args,$vars) = '';
44 @dotsh = split (/\s/, $dotsh);
45 $command = shift (@dotsh);
46 $args = join (" ", @dotsh);
47 $vars = join ("\n", @sh);
48 open (_SH_ENV, "$command") || die "Could not open $dotsh!\n";
50 $shell = "$1 -c" if ($_ =~ /^\#\!\s*(\S+(\/sh|\/ksh|\/zsh|\/csh))\s*$/);
53 if ($ENV{'SHELL'} =~ /\/sh$|\/ksh$|\/zsh$|\/bash$|\/csh$/) {
54 $shell = "$ENV{'SHELL'} -c";
56 print "SHELL not recognized!\nUsing /bin/sh...\n";
57 $shell = "/bin/sh -c";
60 if (length($vars) > 0) {
61 open (_SH_ENV, "$shell \"$vars && . $command $args && set \" |") || die;
63 open (_SH_ENV, "$shell \". $command $args && set \" |") || die;
73 foreach $key (keys(%ENV)) {
74 $tmp .= "\$$key = \$ENV{'$key'};" if $key =~ /^[A-Za-z]\w*$/;