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

Re: [perl #107296] File::Glob::bsd_glob undocumented default flags

Thread Previous | Thread Next
From:
Marc Lehmann
Date:
December 30, 2011 00:59
Subject:
Re: [perl #107296] File::Glob::bsd_glob undocumented default flags
Message ID:
20111230085915.GA20319@schmorp.de
On Thu, Dec 29, 2011 at 07:06:37PM -0800, James E Keenan via RT <perlbug-followup@perl.org> wrote:
> ... which is different from you're claiming, as the default
> (single-argument) does *not* include GLOB_NOCHECK.  Can you clarify?

Well, I tried again with activestate perl, debians and my perl, and all
return the glob pattern if it doesn't match anything:

   # This is perl, v5.10.1 built for MSWin32-x86-multi-thread
   win2k /c/perl$ ls -ld xyzzy
   ls: cannot access xyzzy: No such file or directory
   [Exit 2] 
   win2k /c/perl$ /c/perl/bin/perl -MFile::Glob -e 'die File::Glob::bsd_glob "xyzzy"'
   xyzzy at -e line 1.
   *win2k /c/perl$ /c/perl/bin/perl -MFile::Glob -e 'die File::Glob::bsd_glob "xyzzy", 0'
   Died at -e line 1.

   # This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi
   # /usr/bin/perl -MFile::Glob -e 'die File::Glob::bsd_glob "xyzzy"'
   xyzzy at -e line 1.

   # This is perl 5, version 12, subversion 4 (v5.12.4) built for x86_64-linux
   # perl -MFile::Glob -e 'die File::Glob::bsd_glob "xyzzy"'
   xyzzy at -e line 1.
   # perl -MFile::Glob -e 'die File::Glob::bsd_glob "xyzzy", 0'
   Died at -e line 1.

The behaviour of bsd_glob without arguments is definitely different than
the behaviour with just a "0" here.

In fact, I looked at 5.14.1 and the implementation does this:

            flags = (int) SvIV(get_sv("File::Glob::DEFAULT_FLAGS", GV_ADD));

DEFAULT_FLAGS is an undocumented variable that is initialised in Glob.pm:

   $DEFAULT_FLAGS = GLOB_CSH();
   if ($^O =~ /^(?:MSWin32|VMS|os2|dos|riscos)$/) {
       $DEFAULT_FLAGS |= GLOB_NOCASE();
   }

So the default is even os-specific. scary :)

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp@schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

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