From: Eric Cook <llua@gmx.com>
To: zsh-users@zsh.org
Subject: Re: unintuitive bracketing with return value
Date: Tue, 18 Oct 2022 10:57:33 -0400 [thread overview]
Message-ID: <0ea47ef0-f039-41db-4514-b5b70045a9ef@gmx.com> (raw)
In-Reply-To: <4b6eb0b7-ae82-a81f-6a70-784ffc1d39ff@eastlink.ca>
On 10/18/22 10:47, Ray Andrews wrote:
> 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.
>
>
>
https://mywiki.wooledge.org/BashPitfalls#pf22
next prev parent reply other threads:[~2022-10-18 14:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 14:47 Ray Andrews
2022-10-18 14:57 ` Eric Cook [this message]
2022-10-18 17:57 ` Ray Andrews
2022-10-18 19:32 ` Lawrence Velázquez
2022-10-18 20:12 ` Bart Schaefer
2022-10-18 20:14 ` Bart Schaefer
2022-10-18 20:22 ` Ray Andrews
2022-10-18 20:31 ` Clinton Bunch
2022-10-18 16:07 ` Roman Perepelitsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0ea47ef0-f039-41db-4514-b5b70045a9ef@gmx.com \
--to=llua@gmx.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).