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

Re: whence question



On Sat, Jan 14, 2017 at 09:59:05AM -0800, Bart Schaefer wrote:
> On Sat, 14 Jan 2017, Jens Elkner wrote:
> 
> > especially in 'for' like statements, dropping it silently makes sense
> > (is expected). To accomplish this in an easy way, ksh93 allows one to
> > prefix the pattern with '~(N)' , e.g.:
> >
> > Would be nice, if zsh could do the same (and enhance compatibility) ...
> 
> Zsh has had this for many years, except you suffix the pattern rather
> than prefix it and there's no extra "~":
> 
>     for F in *.c(N) ; do ls $F ; done

Ah ok - good to know, thanx.
  
> Zsh can't readily adopt ksh's exact syntax here because ~(N)*.c is taken
> to be a pattern grouping, e.g. ~(N|M)*.c would match home directories
> for user names beginning with N or M and ending in .c.

Well, it is a special case, which needs some snooping, but does not
really collide with your example: as soon as something different than
'N' appears inside the parens, it can be handled as usual, otherwise
add the corresponding flag to the pattern (or wherever it is needed in
the state machine). If one really wants to have something from the
user[s] N* only, one can/should simply omit the parens - IMHO no big deal.

Have fun,
jel.
-- 
Otto-von-Guericke University     http://www.cs.uni-magdeburg.de/
Department of Computer Science   Geb. 29 R 027, Universitaetsplatz 2
39106 Magdeburg, Germany         Tel: +49 391 67 52768



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