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

Re: bracket expressions and POSIX



On Jun 29,  2:22pm, Clint Adams wrote:
} Subject: bracket expressions and POSIX
}
} 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]

Try it with `emulate -R sh'.  Just `emulate sh' does not turn on all the
POSIX shell emulation options -- in particular `banghist' is still set,
and history references take precedence over glob patterns.

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

With `emulate -R sh' I get:

$ ls
\test  abc
$ echo [!a]*
\test
$ echo [\!a]*			<- That one is especially odd.
\test
$ echo [\]*
[]*
$ echo [\\]*
\test
$ setopt badpattern
$ echo [\]*
zsh: bad pattern: []*

So it appears that zsh is in fact not POSIX-compliant with respect to
backslashes inside brackets, but is OK with respect to `!'.

$ echo [\\!a]*     
\test abc


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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