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

libGdx unable to find files in android application data directory -

php - Webix Data Loading from Laravel Link -

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