Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: 3.1.5: Case-insensitive globbing (2)



(The necessity for the extra patch turned up while I was thinking
about these examples, see below.)

"Bart Schaefer" wrote:
> However, I'm curious how (#i) interacts with parenthesis for grouping.
> For example:
> 
> zsh% echo zsh-3.1.5/((#i)src/zle|doc/zsh)/make*
> 
> Where does the case-insensitivity stop in that expression?  It would be
> logical for it to stop at either the vertical bar or the close paren.

To the best of my knowedge, zsh has never allowed grouping to cross
directories, i.e. not even (Src/Zle) is supported.  You'll find that
everything between the / and the next ) is ignored.  This is because
the path segment code, which is separate from the pattern matching
code, has never been rewritten to understand grouping.  So the
question has never (yet) arisen.  It's always seemed like a long job
to fix this, so I for one have never thought seriously about it.
Documenting it might be an idea.

In the case above,

% echo zsh-3.1.5/(#i){src/zle,doc/zsh}/(#I)make*

should work if you know there are files matching both branches of the
{...}.  Whoops, there's a minor bug:  (#I) wasn't turned off for the
`make' string.  The patch fixes that.

> BTW, is there going to be a parsing conflict between things like
> ((#i)src) and math expressions in (( ))?  How do you get the desired
> glob behavior if there is?

The conflict only applies to words in command position, either on the
line itself or at the start of a $(...) where there is a confusion
with $((...)).  It turns out that ((#i)src) at the start of the line
is interpreted as starting two subshells, followed by a comment.

However, once again it looks like even the existing behaviour is a bit
counter-intuitive:

% /(bin|var)/false
zsh: permission denied: /

It seems zsh treats (and has always treated) left parentheses inside the
command word differently.  When you think about it, it's probably
obvious because it's expected to parse a whole command string at once,
so if it's sensitive to a `(' at the start it will be anywhere else in
the word.

So you can't have any form of grouping in the command word.  But is it
a good idea?  You don't know beforehand what command it's going to
run.

*** Src/glob.c.ci2	Thu Nov  5 10:20:04 1998
--- Src/glob.c	Thu Nov  5 10:17:58 1998
***************
*** 579,585 ****
  		return NULL;
  	    if (eptr == cstr) {
  		/* if no string yet, carry on and get one. */
! 		c->stat |= addflags;
  		cstr = pptr;
  		continue;
  	    }
--- 579,585 ----
  		return NULL;
  	    if (eptr == cstr) {
  		/* if no string yet, carry on and get one. */
! 		c->stat = addflags;
  		cstr = pptr;
  		continue;
  	    }
-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarotti 2, 56100 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author