It seems that set -e is stripped from the options ($-) when executing
commands with command substitution:

$ bash -euc 'echo $-; f(){ false; echo $->&2; }; x=$(f)'
ehuBc
huBc

I would expect the shell to exit as soon as it executes 'false'.

Is this intended? Is it documented somewhere?

I'm trying to catch errors in shellscripts by starting them with:

  set -euo pipefail

It seems now that this is not enough, I would have to start every
command substitution with set -e:

  var=$(set -e; command1; command2)

It *seems* to work with only a single command, because the return
value of the assignment is the last command executed inside the
command substitution. But if there are multiple commands, or a
function call, errors are not caught.

Chris
-- 
echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3

Reply via email to