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

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -