develooper Front page | perl.perl5.porters | Postings from October 2011

Re: [perl #96116] File::Glob ':glob' causes infinite loop

Thread Previous | Thread Next
From:
Ed Avis
Date:
October 26, 2011 03:00
Subject:
Re: [perl #96116] File::Glob ':glob' causes infinite loop
Message ID:
loom.20111026T115439-622@post.gmane.org
Father Chrysostomos via RT <perlbug-followup <at> perl.org> writes:

>The worst breakage is that a glob pattern with spaces gets backslash
>escapes processed three times on Unix, so use this if you want to find
>all files beginning with \ or . :
>
>@files = <\\\\\\\\* .*>;
>
>Fortunately, I’ve fixed that, so you only need four backslashes now.

That's great news!  <g>

I do wonder why this particular bug is considered a bug to be fixed,
while the breakage with space characters is considered a feature to be
preserved.  I know there is some existing code with <*.c *.h> but that is
not difficult to fix - so under 'use 5.16' glob could have sensible semantics.

>>    my $dirname = shift @ARGV;
>>    my $quoted = quotemeta $dirname;
>>    my @g = glob "$quoted/*";
>> 
>>That seems dirty, and won't work under Windows, where glob() takes
>>backslash as a directory separator.
>
>Slash also works.

Yup, but since backslash works too, the business of backslash-escaping glob
patterns is even messier on Windows than on Unix.  (at least for common patterns
such as */* which might equally be given as *\* on Windows)

-- 
Ed Avis <eda@waniasset.com>


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About