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

Re: Pattern matching: backslash escaping not active in pattern passed from variable



On Mon, 18 May 2015 10:33:31 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On Mon, May 18, 2015 at 5:07 AM, Martijn Dekker <martijn@xxxxxxxx> wrote:
> > Peter Stephenson's patch for case pattern matching applied cleanly
> > against the latest git code and is working perfectly. Many thanks.
> >
> > There is another snag I've found in pattern matching, which seems to
> > have survived this patch: backslash escaping does not seem match the
> > standard if a glob pattern is passed from a variable or parameter. The
> > standard says:
> [...]
> > In any case, I would expect backslash escaping to work the same way
> > whether the glob pattern is passed from a variable or parameter or not.
> 
> see the GLOB_SUBST option.

GLOB_SUBST roughly covers the last remark (and GLOB_SUBST is on in POSIX
mode), but not the thing about backslashes --- zsh only removes the
backslashes around pattern characters, not other characters, if it knows
the context is just quoting patterns, which is true of characters made
"live" by the effect of GLOB_SUBST.  That's why the new (b) parameter
expansion flag turned up.

I suppose that ought to be fixable in compatibility mode --- we
certainly don't want to mess around with quoting in native mode.

(I said "roughly" above because there's a big can of worms here about
when quoting happens --- normal backslash quoting happens on input to
the lexer, backslash quoting of patterns much later and in this case
possibly in addition --- but the intention is GLOB_SUBST should at least
make zsh look like other shells, messy though that is.)

pws



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