bash - linux curly brackets instead of if-then-else-fi do-done -
are curly brackets suitable replacement other constructs?
[ -n "$test" ] && { xx='yes'; echo 'yes' } || { xx='no'; echo 'no' } vs
if [ -n "$test" ] ; xx='yes'; echo 'yes' else xx='no'; echo 'no' fi another:
num in {000..2}; echo "$num"; done or
num in {000..2}; { echo "$num"; }
in first example, a && b || c , if a; b else c have different behavior if b has non-zero exit status.
[ -n "$test" ] && { echo this; false; } || { echo "this too?"; } your second example is should syntax error. nothing in documentation says can replace do/done pair compound command (which {...} is).
update: i'm told maintainer of bash undocumented feature provides backwards compatibility undocumented feature in original bourne shell.
Comments
Post a Comment