Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
unintuitive bracketing with return value
- X-seq: zsh-users 28223
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: unintuitive bracketing with return value
- Date: Tue, 18 Oct 2022 07:47:04 -0700
- Archived-at: <https://zsh.org/users/28223>
- List-id: <zsh-users.zsh.org>
I vaguely remember mentioning this before but I don't recall what the
understanding should be:
[ "${${1}##*[*?]*}" ] && {
echo "no wildcards"; printenv "$1" } || echo wildcards present
... I'm obviously testing for the presence of wildcards before sending
"$1" to 'printenv', unfortunately the '||' responds to the return value
of 'printenv' and not, as I intend, for the '||' to respond to the first
test (presence of wildcards). If it was not bracketed there would be no
issue of course, but shouldn't the brackets do the intuitive thing and
force the final '||' to be the alternative to the first '&&'? It's easy
to just write the thing as an 'if/else' statement and avoid the issue,
but still the above seems very counter intuitive. ... Tho of course one
could get used to it and prefer it that way but still it seems weird.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author