Re: Possible bug in bash

2022-05-12 Thread Robert Elz
Not a bug. Do not use && || as if they were a replacement for if then else fi they aren't. In some simple cases it all works out OK, but not in general, as you discovered. If you mean if x; then y; else z; fi then write that, not x && y || z The way and-or lists work, is that the first command

Re: Possible bug in bash

2022-05-12 Thread Lawrence Velázquez
On Thu, May 12, 2022, at 11:34 PM, flyingrhino wrote: > Should the "else" condition after the: || run if the last command in > the: && section exits non zero? Yes. This behavior is not a bug; ''A && B || C'' is simply not equivalent to ''if A then B; else C; fi''. https://mywiki.wooledge.or

Possible bug in bash

2022-05-12 Thread flyingrhino
Hi, Should the "else" condition after the: || run if the last command in the: && section exits non zero? I tested it this way: Script: #!/bin/bash [[ "a" == "a" ]] && \ { echo "equal" ls x } || { echo "* SHOULD NOT DISPLAY 4" } Result: ./moo.sh equal ls: