zsh-users
 help / color / mirror / code / Atom feed
* unintuitive bracketing with return value
@ 2022-10-18 14:47 Ray Andrews
  2022-10-18 14:57 ` Eric Cook
  2022-10-18 16:07 ` Roman Perepelitsa
  0 siblings, 2 replies; 9+ messages in thread
From: Ray Andrews @ 2022-10-18 14:47 UTC (permalink / raw)
  To: Zsh Users

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.




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-10-18 20:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18 14:47 unintuitive bracketing with return value Ray Andrews
2022-10-18 14:57 ` Eric Cook
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

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).