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

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -