Ignore:
Timestamp:
2011-11-30T20:01:30+13:00 (12 years ago)
Author:
ak19
Message:
  1. util.pm's envvar_prepend and append subroutines now escape backslashes for internal regex operations not only for windows but throughout, and the filename_to_regex subroutine also escapes backslashes for all OS now. 2. makegs2.bat prints a warning at the very end to tell the user that the command prompt has been left in shortfilename mode.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/util.pm

    r24829 r24832  
    838838
    839839    # need to put single backslash back to double so that regex works
    840     if ($ENV{'GSDLOS'} =~ /^windows$/i) {
    841         $filename =~ s/\\/\\\\/g;
    842     }
     840    $filename =~ s/\\/\\\\/g; # if ($ENV{'GSDLOS'} =~ /^windows$/i);   
    843841   
    844     # note that the first part of a substitution is a regex, so RE chars need to be escaped,
    845     # the second part of a substitution is not a regex, so for e.g. full-stop can be specified literally
     842    # note that the first part of a substitution is a regex, so RE chars need to be escaped,
     843    # the second part of a substitution is not a regex, so for e.g. full-stop can be specified literally
    846844    $filename =~ s/\./\\./g; # in case there are extensions/other full stops, escape them
    847845    $filename =~ s@\(@\\(@g; # escape brackets
     
    944942
    945943    # do not prepend any value/path that's already in the environment variable
    946     if ($ENV{'GSDLOS'} =~ /^windows$/i)
    947     {
    948     my $escaped_val = &filename_to_regex($val); # escape any Windows backslashes and brackets for upcoming regex
    949     if (!defined($ENV{$var})) {
    950         $ENV{$var} = "$val";
    951     }
    952     elsif($ENV{$var} !~ m/$escaped_val/) {
    953         $ENV{$var} = "$val;".$ENV{$var};
    954     }
    955     }
    956     else {
    957     if (!defined($ENV{$var})) {
    958         $ENV{$var} = "$val";
    959     }
    960     elsif($ENV{$var} !~ m/$val/) {
    961         $ENV{$var} = "$val:".$ENV{$var};
    962     }
     944   
     945    my $escaped_val = &filename_to_regex($val); # escape any backslashes and brackets for upcoming regex
     946    if (!defined($ENV{$var})) {
     947    $ENV{$var} = "$val";
     948    }
     949    elsif($ENV{$var} !~ m/$escaped_val/) {
     950    $ENV{$var} = "$val;".$ENV{$var};
    963951    }
    964952}
     
    966954sub envvar_append {
    967955    my ($var,$val) = @_;
    968 
     956   
    969957    # do not append any value/path that's already in the environment variable
    970     if ($ENV{'GSDLOS'} =~ /^windows$/i)
    971     {
    972     my $escaped_val = &filename_to_regex($val); # escape any Windows backslashes and brackets for upcoming regex
    973     if (!defined($ENV{$var})) {
    974         $ENV{$var} = "$val";
    975     }
    976     elsif($ENV{$var} !~ m/$escaped_val/) {
    977         $ENV{$var} .= ";$val";
    978     }
    979     }
    980     else {
    981     if (!defined($ENV{$var})) {
    982         $ENV{$var} = "$val";
    983     }
    984     elsif($ENV{$var} !~ m/$val/) {
    985         $ENV{$var} .= ":$val";
    986     }
    987     }   
     958   
     959    my $escaped_val = &filename_to_regex($val); # escape any backslashes and brackets for upcoming regex
     960    if (!defined($ENV{$var})) {
     961    $ENV{$var} = "$val";
     962    }
     963    elsif($ENV{$var} !~ m/$escaped_val/) {
     964    $ENV{$var} .= ";$val";
     965    }
    988966}
    989967
Note: See TracChangeset for help on using the changeset viewer.