tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: glob(3) extension



 Wed, Feb 13, 2008 at 21:35:37, mouse wrote about "glob(3) extension": 

> I propose an addition to glob(3): GLOB_HIDE_DOTDIRS, which makes . and
> .. vanish when matching wildcards, even if GLOB_PERIOD is set.

> Comments?  (I'm going to implement it for my own use, but would find it
> convenient to have it in the tree.)

I would prefer flag with the following result:

pattern.startswith("*") => match any name except one starting with '.'
  (i.e. set GLOB_PERIOD implicitly)
pattern.startswith("**") => match any name except "." and ".."
  (i.e. set GLOB_HIDE_DOTDIRS implicitly)
pattern.startswith("***") => match any name
pattern.startswith(".*") => match any name starting with '.' except "." and ".."
  (i.e. set GLOB_HIDE_DOTDIRS implicitly)
pattern.startswith(".**") => match any name starting with '.'

 ... and make it default for /bin/sh except Posix compatible mode is requested.

(of course, its result shall be limited according to tail of the pattern)

In this way we will cure innate patology of glob matching.


-netch-


Home | Main Index | Thread Index | Old Index