shopt-option

Bash inherit_errexit

Keep the errexit setting in ordinary command substitution instead of clearing it in non-POSIX mode.

Formal Syntax & Structure

bash syntaxbash
shopt -s inherit_errexit

Return Value

exit status

Keep the errexit setting in ordinary command substitution instead of clearing it in non-POSIX mode.

Working Example

Example Snippetbash
bash -c 'set -e; shopt -u inherit_errexit; v=$(false; printf survived); printf "%s\n" "$v"'bash -c 'set -e; shopt -s inherit_errexit; v=$(false; printf unreachable); printf "%s\n" "$v"'printf 'inherited status=%s\n' "$?"
Bash Reference