bash - Functional difference between if-then and command group -
is there functional advantage of using simple if-then statement such as
if [ … ];
over using short-circuit list evaluators command groups such as
[ … ] && { }
of course, if-then standard way of writing it, there actual difference/advantage functional point of view?
using ()
instead of {}
spawn new subshell, creating new scope variables inside if-then block.
not example, commonly seen
condition && foo || bar
is not same
if condition foo else bar fi
in former case, bar
run not if condition
fails, if foo
fails.
Comments
Post a Comment