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

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

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
October 26, 2011 08:32
Subject:
[perl #96116] File::Glob ':glob' causes infinite loop
Message ID:
rt-3.6.HEAD-31297-1319643139-1430.96116-15-0@perl.org
On Wed Oct 26 03:00:32 2011, eda@waniasset.com wrote:
> 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,

Because it wasn’t self-consistent.  These two patterns produced the same
results:

  <\\\\\\\\* .*>   <{\\\\,.}*>

> while the breakage with space characters is considered a feature to be
> preserved.  I know there is some existing code with <*.c *.h>

A *lot* of existing code.

> 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)
> 




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