shopt-option

Bash shopt execfail

Allows a noninteractive shell to continue if exec fails, rather than exiting immediately. A successful exec still replaces the shell. Capture the failure status explicitly. Fixture invokes a nonexistent path in the private directory and retains its diagnostic in a local file. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): continued=127.

Formal Syntax & Structure

bash syntaxbash
shopt -s execfail; shopt -u execfail; shopt -q execfail

Return Value

exit status

Option-setting command returns zero for a valid request; query status is zero if enabled, one if disabled.

Working Example

Example Snippetbash
shopt -s execfailexec ./absent 2> error.logrc=$?[[ $rc != 0 && -s error.log ]] || exit 1printf 'continued=%s\n' "$rc"
Bash Reference