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

Re: strange glob parsing



On Mon, Jun 2, 2025 at 8:19 PM Lawrence Velázquez <larryv@xxxxxxx> wrote:
>
> It's not what I expect.  I believe that POSIX requires the synonymous
> "[!]" to match a literal '[' followed by a literal '!' followed by
> a literal ']', and bash, dash, and ksh perform matching this way.

There's a comment in pattern.c:

             * []...] means match a "]" or other included characters.
             * However, to be a bit helpful and for compatibility
             * with other shells, don't take in that sense if
             * there's no further "]".  That's still imperfect,
             * but it's all we can do --- we're required to
             * treat [$var]*[$var]with empty var as [ ... ]
             * containing "]*[".

This is followed by a lookahead from ']' to find an optional next ']'.




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