Changeset 16404

Show
Ignore:
Timestamp:
15.07.2008 12:10:30 (12 years ago)
Author:
ak19
Message:

Subroutines envvar_prepend and envvar_append now only append a new value or path if the envvar does not already contain it. Without this, my PATH variable had grown unmanageably long.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/util.pm

    r16380 r16404  
    629629    my $current_val = $ENV{$var}; 
    630630     
    631     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
    632     $ENV{$var} .= "$val;$current_val"; 
    633     } 
    634     else { 
    635     $ENV{$var} .= "$val:$current_val"; 
     631    # do not prepend any value/path that's already in the environment variable 
     632    if($ENV{$var} !~ m/$val/) {  
     633    if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     634        $ENV{$var} .= "$val;$current_val"; 
     635    } 
     636    else { 
     637        $ENV{$var} .= "$val:$current_val"; 
     638    } 
    636639    } 
    637640} 
     
    640643    my ($var,$val) = @_; 
    641644 
    642     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
    643     $ENV{$var} .= ";$val"; 
    644     } 
    645     else { 
    646     $ENV{$var} .= ":$val"; 
     645    # do not append any value/path that's already in the environment variable 
     646    if($ENV{$var} !~ m/$val/) {  
     647    if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     648        $ENV{$var} .= ";$val"; 
     649    } 
     650    else { 
     651        $ENV{$var} .= ":$val"; 
     652    } 
    647653    } 
    648654}