X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/28cd8e1dfd44684db52b0c0d0ceafbe8b1be8d4e..edfed4c3099abba2a8b83e8dde6bcff0952c07f5:/ext/File-Glob/Glob.pm diff --git a/ext/File-Glob/Glob.pm b/ext/File-Glob/Glob.pm index eead378..f9f0edd 100644 --- a/ext/File-Glob/Glob.pm +++ b/ext/File-Glob/Glob.pm @@ -36,7 +36,7 @@ use feature 'switch'; @EXPORT_OK = (@{$EXPORT_TAGS{'glob'}}, 'csh_glob'); -$VERSION = '1.10'; +$VERSION = '1.14'; sub import { require Exporter; @@ -77,22 +77,6 @@ my %entries; sub csh_glob { my $pat = shift; my $cxix = shift; - my @pat; - - # glob without args defaults to $_ - $pat = $_ unless defined $pat; - - # extract patterns - $pat =~ s/^\s+//; # Protect against empty elements in - $pat =~ s/\s+$//; # things like < *.c> and <*.c >. - # These alone shouldn't trigger ParseWords. - if ($pat =~ /\s/) { - # XXX this is needed for compatibility with the csh - # implementation in Perl. Need to support a flag - # to disable this behavior. - require Text::ParseWords; - @pat = Text::ParseWords::parse_line('\s+',0,$pat); - } # assume global context if not provided one $cxix = '_G_' unless defined $cxix; @@ -100,6 +84,27 @@ sub csh_glob { # if we're just beginning, do it all first if ($iter{$cxix} == 0) { + my @pat; + + # glob without args defaults to $_ + $pat = $_ unless defined $pat; + + # extract patterns + $pat =~ s/^\s+//; # Protect against empty elements in + # things like < *.c>, which alone + # shouldn't trigger ParseWords. Patterns + # with a trailing space must be passed + # to ParseWords, in case it is escaped, + # as in glob('\ '). + if ($pat =~ /[\s"']/) { + # XXX this is needed for compatibility with the csh + # implementation in Perl. Need to support a flag + # to disable this behavior. + require Text::ParseWords; + for (@pat = Text::ParseWords::parse_line('\s+',1,$pat)) { + s/^['"]// and chop; + } + } if (@pat) { $entries{$cxix} = [ map { doglob($_, $DEFAULT_FLAGS) } @pat ]; }