Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Builtin test and parsing of conditionals
- X-seq: zsh-workers 31693
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Builtin test and parsing of conditionals
- Date: Wed, 04 Sep 2013 09:15:03 -0700
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
According to some discussion on the austin-group (POSIX) mailing list,
the following:
test ! -a !
test ! -o !
test ! = !
should all be parsed as comparing the string "!" to the string "!", but
zsh gets this right only in the last case.
This is especially annoying because
test ! -f !
should be interpreted as the negation of the unary file-exists operator.
This is probably complicated by the different meanings of -a and -o in
[[ ... ]] as opposed to "test" because the same parser is used.
Furthermore:
test ! = -o a
should be parsed as the negation of the comparison between the strings "="
and "a", implying that zsh also gets this wrong:
test ! = = =
which should return false (negation of (equal is the same string as equal)),
rather than give a parse error as zsh does. (Zsh does get
test = = =
right.)
Apparently the only way to do this correctly is to examine both argv[1] and
the number of arguments, and skip to argv[2] for recursive descent parsing
when argv[1] is "!" and there are four arguments. (As already mentioned in
the zsh manual, what to do with more than four arguments in the absence of
explicit parens is unclear [unspecified?].)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author