| POSIX allows it (leaves [^x] unspecified) but does not require
  | it. Once ksh88 dies away or maintainers of ksh88-based shells
  | eventually come around to adding it there, POSIX will be able to
  | mandate it without problem.

Not quite "without problem" ... implementations implement it (most anyway,
as you said) as in practice it works fine, but in general, having alternative
"not" chars makes a mess of the [] interpretation rules.   These days we'd
just quote the ! or ^ to allow one of those literally in a [] expression
in a glob, but that wasn't always possible - the technique was that that
character worked as magic only when first (immediately after the '[') so
to include it literally it was simply put any place else (there is always
somewhere else, as [!] (or [^]) makes no sense as a way to match exactly
! (or ^) as just the char itself without the [] means the same, and in any
case is invalid as a ']' is not the [] terminating ']' if it immediately
follows the ']', or the negation char, if it is present).

But two different chars cannot both always both be not first, eg [!^]
which is "anything except ^" and if ^ is not special, then [^!] is
"either ! or ^" but if it is, then that is "anything but !" which then
makes it impossible to say "either ! or ^" (without quoting working,
with it, it is of course trivial).

That might be just enough to make it difficult to require ^ as an
alternative to ! (replacing ! by ^ would work easily, but that is never
going to happen).

Naturally, since most shells already support it, the problem exists
anyway in practice -- or doesn't, as about the only thing that would want
to match either a ! or a ^ (and nothing else) would be something matching
glob [] expressions ... and while one might write a RE to do that, writing
a glob to match globs seems kind of unlikely to be useful.

kre


Reply via email to