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

What gave you that idea? I would be highly surprised if POSIX had different
rules as XPG and SUS; and according to SUS the following still matches abc:

a["\b"]c

Actually, SUS explicitly speaks about both quoting (when parsed by shell)
and escaping (when pattern is interpreted).

<http://www.opengroup.org/onlinepubs/007908799/xcu/chap2.html#tag_001_013>

Note, that patterns in shell are *based* on regular expressions but not
identical (that probably has confused you).

                                                (anyone remember off
> the top of their head how to match both a `]' and a `-'?).

If a bracket expression must specify both - and ], the ] must be placed
first (after the ^, if any) and the - last within the bracket expression.

Where zsh really violates POSIX:

==
Since each asterisk matches zero or more occurrences, the patterns a*b and
a**b have identical functionality
==

Another point is using collating elements, ranges etc ... anything that has
to deal with locale.

-andrej



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