Registered: 13/07/2000
Posts: 4182
Loc: Cambridge, England
Invoking exit always terminates the shell. But $(...) forks and runs the function in a sub-shell, so in that case it's the sub-shell which terminates. You can use $? to read the status (success or failure) of the most recent sub-shell, or add "set -e" to your script to make it error on failing sub-shells.