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

Re: bracket expressions and POSIX



Clint Adams wrote:
> POSIX says that \ loses its special meaning within a bracket
> expression for pattern matching and also that ! is the
> ^ character in that context.
> 
> So this strikes me as non-compliant:
> 
> % emulate sh
> % touch \\test abc
> % echo [!a]*
> zsh: event not found: a]

We can't do much directly about this (i.e. with BANG_HISTORY), as Bart
pointed out.

> % echo [\!a]*
> \test

Ooh err.  I don't like that one at all.

> % echo [\]*
> []*
> % echo [\\]*
> \test

These are non-compliant, but it's actually useful being able to quote
things in a range with a backslash, particularly square brackets, rather
than rely on the rather tricky rules of positioning (anyone remember off
the top of their head how to match both a `]' and a `-'?).  I hope
it will be possible to turn this into an option (part of SH_GLOB?) by
un-nulling the backslashes.  It's possible the extra test could make a
noticeable effect on the speed of pattern compilation, but again I hope
not.  I haven't looked at the code.

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk



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