@EXPORT_OK = (@{$EXPORT_TAGS{'glob'}}, 'csh_glob');
-$VERSION = '1.13';
+$VERSION = '1.14';
sub import {
require Exporter;
# 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/) {
+ # 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 <\ >.
+ 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);
+ for (@pat = Text::ParseWords::parse_line('\s+',1,$pat)) {
+ s/^['"]// and chop;
+ }
}
# assume global context if not provided one
}
}
use strict;
-use Test::More tests => 18;
+use Test::More tests => 23;
BEGIN {use_ok('File::Glob', ':glob')};
use Cwd ();
# This used to segfault.
my $i = bsd_glob('*', GLOB_ALTDIRFUNC);
is(&File::Glob::GLOB_ERROR, 0, "Successfuly ignored unsupported flag");
+
+package frimpy; # get away from the glob override, so we can test csh_glob,
+use Test::More; # which is perl's default
+
+is +(glob "a'b'")[0], (<a'b' c>)[0], "a'b' with and without spaces";
+is +(<a"b">)[0], (<a"b" c>)[0], 'a"b" with and without spaces';
+is <\\*>, '*', 'backslashes without spaces';
+is_deeply [sort <\\* .\\*>], [sort qw<* .*>], 'backslashes with spaces';
+is <\\ >, ' ', 'final escaped space';