Loading...

`exit` inside parentheses doesn't exit script

Answer #1 100 %

The parentheses execute their contents in a subshell, it is therefore the subshell that exits.

You would usually achieve the same effect either with another && or using {} instead of ().

{ echo "Test 1"; exit; } && echo "Test 2"

Or

echo "Test 1" && exit && echo "Test 2"
Tags: linuxbash

You’ll also like:


© 2023 CodeForDev.com -