This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: file globbing


On Thu, 17 Feb 2005, James Lemke wrote:

> Date: Thu, 17 Feb 2005 10:31:37 -0500
> From: James Lemke <jim@TheLemkes.ca>
> To: cygwin@cygwin.com
> Subject: file globbing
> 
> I've recently noticed a problem with Cygwin ls.  I did a quick search of

It's not ls that does the globbing. That is done by the shell before it
runs ls.

> the archives, but didn't get any hits.  Has anyone else seen this?
> Try: ls -dl ../tcl[7-9]*
> Result on Linux: ../tcl ../tcl8
> Result on Cygwin: ../tcl8
> 
> That is, on Cygwin tcl[7-9]* does not match tcl.  I think it should.

It should not. Shell regular expressions for globbing filenames are not
the same as normal regular expressions. [7-9]* does not mean ``zero or
more occurences of a character in the 7-9 class'' it means ``exactly
one occurence of 7, 8 or 9 followed by zero or more characters''.

Not sure what is going on with the Linux example.

If you are investigating glob behavior, try using echo rather than ls:

  echo ../tcl[7-9]*

If there is any confusion about what is being matched due to leading,
trailing or embedded whitespace, try this:

  for x in <pattern>; do echo "<$x>"; done

Then you get each matching name, in angle braces, on a separate line.

> I have upgraded to the latest coreutils and still see the problem.
> Comments?

The only apparent problem is on the Linux side, where a pattern that
calls for a digit in the range 7-8 seems to be matching a name that
contains no such thing.

It does look like the shell you are using on Linux is interpreting the
pattern as a full regular expression.

-- 
Meta-CVS: the working replacement for CVS that has been stable since
2002.  It versions the directory structure, symbolic links and execute
permissions. It figures out renaming on import. Plus it babysits the kids
and does light housekeeping! http://freshmeat.net/projects/mcvs


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]