From: apeiron Date: Fri, 14 Sep 2007 01:16:22 +0000 (+0000) Subject: Move the shell detection code *out* of the while loop. X-Git-Tag: 1.006009~103 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0353dbc0d1ccaa85429d93bbc2e0e84312013c26;p=p5sagit%2Flocal-lib.git Move the shell detection code *out* of the while loop. apeiron-- /kick apeiron idiot git-svn-id: http://dev.catalyst.perl.org/repos/bast/local-lib/1.000/trunk@3739 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/lib/local/lib.pm b/lib/local/lib.pm index 355278e..013fe87 100644 --- a/lib/local/lib.pm +++ b/lib/local/lib.pm @@ -188,20 +188,20 @@ sub print_environment_vars_for { my ($class, $path) = @_; my @envs = $class->build_environment_vars_for($path, LITERAL_PATH); my $out = ''; + # rather basic csh detection, goes on the assumption that something won't + # call itself csh unless it really is. also, default to bourne in the + # pathological situation where a user doesn't have $ENV{SHELL} defined. + # note also that shells with funny names, like zoid, are assumed to be + # bourne. + my $shellbin = 'sh'; + if(defined $ENV{'SHELL'}) { + my @shell_bin_path_parts = File::Spec->splitpath($ENV{'SHELL'}); + $shellbin = $shell_bin_path_parts[-1]; + } while (@envs) { my ($name, $value) = (shift(@envs), shift(@envs)); $value =~ s/(\\")/\\$1/g; - # rather basic csh detection, goes on the assumption that something won't - # call itself csh unless it really is. also, default to bourne in the - # pathological situation where a user doesn't have $ENV{SHELL} defined. - # note also that shells with funny names, like zoid, are assumed to be - # bourne. - my $shellbin = 'sh'; - if(defined $ENV{'SHELL'}) { - my @shell_bin_path_parts = File::Spec->splitpath($ENV{'SHELL'}); - $shellbin = $shell_bin_path_parts[-1]; - } if($shellbin =~ /csh/) { $out .= qq{setenv ${name} "${value}"\n}; }