-------- CASE: no_such_command_commandsub echo $(ZZZZZ) ^~~~~ 'test/runtime-errors.sh':73: 'ZZZZZ' not found SHOULD NOT GET HERE STATUS: 0 -------- CASE: no_such_command_heredoc $(ZZZZZ) ^~~~~ 'test/runtime-errors.sh':84: 'ZZZZZ' not found one three SHOULD NOT GET HERE STATUS: 0 -------- CASE: errexit_usage_error type -z ^~ 'test/runtime-errors.sh':101: 'type' doesn't accept flag -z STATUS: 0 -------- CASE: errexit_subshell subshell STATUS: 0 -------- CASE: errexit_pipeline 0 STATUS: 0 -------- CASE: errexit_dbracket STATUS: 0 -------- CASE: errexit_alias foo is a alias hi ls: cannot access '/nonexistent': No such file or directory STATUS: 0 -------- CASE: errexit_one_process zz ^~ [ -c flag ]:1: 'zz' not found [ -c flag ]:1: errexit PID 13545: command.Simple failed with status 127 --------------------------- echo hi > "" ^ [ -c flag ]:1: Can't open '': No such file or directory [ -c flag ]:1: errexit PID 13548: command.Simple failed with status 1 --------------------------- shopt -s failglob; echo *.ZZZZ ^ [ -c flag ]:1: failglob: Pattern '*.ZZZZ' matched no files [ -c flag ]:1: errexit PID 13551: command.Simple failed with status 1 --------------------------- cd /x ^~ [ -c flag ]:1: cd '/x': No such file or directory cd /x ^~ [ -c flag ]:1: errexit PID 13554: command.Simple failed with status 1 --------------------------- ./README.md; echo hi ^~~~~~~~~~~ [ -c flag ]:1: Can't execute './README.md': Permission denied hi --------------------------- ./README.md; echo hi ^~~~~~~~~~~ [ -c flag ]:1: Can't execute './README.md': Permission denied ./README.md; echo hi ^~~~~~~~~~~ [ -c flag ]:1: errexit PID 13561: command.Simple failed with status 126 ls: cannot access '/x': No such file or directory ls /x; echo $? ^~ [ -c flag ]:1: errexit PID 13565: command.Simple failed with status 2 --------------------------- ls: cannot access '/x': No such file or directory declare cmd=ls; $cmd /x; echo $? ^~~~ [ -c flag ]:1: errexit PID 13569: command.Simple failed with status 2 --------------------------- echo $undef ^~~~~~ [ -c flag ]:1: fatal: Undefined variable 'undef' --------------------------- try --allow-status-01 grep ^~~~~~~~~~~~~~~~~ [ -c flag ]:1: 'try' got invalid flag '--allow-status-01' try --allow-status-01 grep ^~~ [ -c flag ]:1: errexit PID 13576: command.Simple failed with status 2 --------------------------- ( ^ [ eval word at line 2 of [ -c flag ] ]:1: Unexpected EOF while parsing command status=2 ) ^ [ eval word at line 5 of [ -c flag ] ]:1: Invalid word while parsing command status=2 false ^~~~~ [ -c flag ]:9: errexit PID 13579: command.Simple failed with status 1 --------------------------- [[ 0 -eq 1 ]] ^~ [ -c flag ]:1: errexit PID 13582: command.DBracket failed with status 1 --------------------------- (( 0 )) ^~ [ -c flag ]:1: You may want a space between parens (parse_dparen) STATUS: 0 -------- CASE: errexit_multiple_processes echo t=$(true) f=$(false; true) ^~~~~ [ -c flag ]:1: errexit PID 13593: command.Simple failed with status 1 [ -c flag ]:1: errexit PID 13589: Command Sub exited with status 1 --------------------------- ls | false | wc -l ^~~~~ [ -c flag ]:1: errexit PID 13598: command.Simple failed with status 1 0 --------------------------- ls | { echo hi; ( exit 42 ); } | wc -l; echo ^ [ -c flag ]:1: errexit PID 13603: command.Subshell failed with status 42 1 ls | { echo hi; ( exit 42 ); } | wc -l; echo ^ [ -c flag ]:1: errexit PID 13599: command.Pipeline failed with status 42 --------------------------- { false; wc -l; } ^~~~~ [ -c flag ]:2: errexit PID 13606: command.Simple failed with status 1 { echo one; ( exit 42 ); } |\ ^ [ -c flag ]:1: errexit PID 13609: command.Subshell failed with status 42 { false; wc -l; } ^ [ -c flag ]:2: errexit PID 13606: command.Pipeline failed with status 1 --------------------------- { ls; false; } \ ^~~~~ [ -c flag ]:1: errexit PID 13614: command.Simple failed with status 1 76 { ls; false; } \ ^ [ -c flag ]:1: errexit PID 13611: command.Pipeline failed with status 1 --------------------------- { ls; ( false; true ); } | wc -l; echo hi ^~~~~ [ -c flag ]:1: errexit PID 13623: command.Simple failed with status 1 { ls; ( false; true ); } | wc -l; echo hi ^ [ -c flag ]:1: errexit PID 13620: command.Subshell failed with status 1 76 { ls; ( false; true ); } | wc -l; echo hi ^ [ -c flag ]:1: errexit PID 13617: command.Pipeline failed with status 1 --------------------------- ls <(sort YY) <(zz); echo hi ^~ [ -c flag ]:1: 'zz' not found [ -c flag ]:1: errexit PID 13628: command.Simple failed with status 127 sort: cannot read: YY: No such file or directory /dev/fd/3 /dev/fd/4 ls <(sort YY) <(zz); echo hi ^~ [ -c flag ]:1: errexit PID 13624: command.Simple failed with status 127 --------------------------- zz <(sort YY) <(sort ZZ); echo hi ^~ [ -c flag ]:1: 'zz' not found sort: cannot read: YY: No such file or directory sort: cannot read: ZZ: No such file or directory [ -c flag ]:1: errexit PID 13630: command.Simple failed with status 127 --------------------------- yy | zz ^~ yy | zz ^~ [ -c flag ]:1: 'zz' not found [ -c flag ]:1: 'yy' not found [ -c flag ]:1: errexit PID 13635: command.Simple failed with status 127 [ -c flag ]:1: errexit PID 13638: command.Simple failed with status 127 yy | zz ^~ [ -c flag ]:1: errexit PID 13635: command.Pipeline failed with status 127 --------------------------- echo $([[ 0 -eq 1 ]]) ^~ [ -c flag ]:1: errexit PID 13645: command.DBracket failed with status 1 [ -c flag ]:1: errexit PID 13639: Command Sub exited with status 1 --------------------------- var y = $([[ 0 -eq 1 ]]) ^~ [ -c flag ]:1: errexit PID 13649: command.DBracket failed with status 1 [ -c flag ]:1: errexit PID 13646: Command Sub exited with status 1 STATUS: 0 -------- CASE: command_sub_errexit STATUS: 0 -------- CASE: process_sub_fail a b STATUS: 0 -------- CASE: pipefail 0 0 STATUS: 0 -------- CASE: pipefail_group 1 1 3 STATUS: 0 -------- CASE: pipefail_subshell 1 1 3 STATUS: 0 -------- CASE: pipefail_no_words seq 3 | wc -l | > /nonexistent ^ 'test/runtime-errors.sh':421: Can't open '/nonexistent': Permission denied STATUS: 0 -------- CASE: pipefail_func 1 1 3 STATUS: 0 -------- CASE: pipefail_while 2 6 12 STATUS: 0 -------- CASE: pipefail_multiple six STATUS: 0 -------- CASE: core_process echo foo > not/a/file ^ 'test/runtime-errors.sh':493: Can't open 'not/a/file': No such file or directory echo foo > /etc/no-perms-for-this ^ 'test/runtime-errors.sh':494: Can't open '/etc/no-perms-for-this': Permission denied STATUS: 0 -------- CASE: osh_state HOME=(a b) ^~~~~ 'test/runtime-errors.sh':503: fatal: Only strings can be exported STATUS: 0 -------- CASE: nounset echo $x ^~ 'test/runtime-errors.sh':599: fatal: Undefined variable 'x' STATUS: 0 -------- CASE: bad_var_ref bad var name ^ [ contents of var 'name' at line 606 of 'test/runtime-errors.sh' ]:1: Expected end of var ref expression echo ${!name} ^~~~ 'test/runtime-errors.sh':606: fatal: Invalid var ref expression STATUS: 0 -------- CASE: nounset_arith echo $(( x )) ^ 'test/runtime-errors.sh':615: fatal: Undefined variable 'x' STATUS: 0 -------- CASE: array_arith 2 2 STATUS: 0 -------- CASE: undef_arith (( undef[42]++ )) ^~ 'test/runtime-errors.sh':683: fatal: Can't use [] on value of type value.Str STATUS: 0 -------- CASE: undef_arith2 ['2'] STATUS: 0 -------- CASE: undef_assoc_array bar STATUS: 0 -------- CASE: string_to_int_arith 5 ZZZ ^~~ [ var ? at line 653 of 'test/runtime-errors.sh' ]:1: fatal: Undefined value in arithmetic context STATUS: 0 -------- CASE: string_to_hex 1 SHOULD NOT GET HERE STATUS: 0 -------- CASE: string_to_octal 1 SHOULD NOT GET HERE STATUS: 0 -------- CASE: string_to_intbase 0 SHOULD NOT GET HERE STATUS: 0 -------- CASE: string_to_int_bool a ^ [ var ? at line 737 of 'test/runtime-errors.sh' ]:1: fatal: Undefined value in arithmetic context STATUS: 0 -------- CASE: string_as_array foo echo "${str[@]}" ^~ 'test/runtime-errors.sh':801: fatal: Can't index string with @ STATUS: 0 -------- CASE: array_assign_1 s[0]=x # can't assign value ^~ 'test/runtime-errors.sh':773: fatal: Can't assign to items in a string STATUS: 0 -------- CASE: array_assign_2 array[0]=x ^~~~~~ 'test/runtime-errors.sh':778: fatal: Can't assign to readonly array STATUS: 0 -------- CASE: readonly_assign x=2 ^~ 'test/runtime-errors.sh':783: fatal: Can't assign to readonly value 'x' STATUS: 0 -------- CASE: multiple_assign a=1 b=2 x=42 ^~ 'test/runtime-errors.sh':789: fatal: Can't assign to readonly value 'x' STATUS: 0 -------- CASE: multiple_assign_2 0 STATUS: 0 -------- CASE: patsub_bad_glob echo ${x//[^]} ^ 'test/runtime-errors.sh':723: fatal: Error matching regex '([^])': Unmatched [ or [^ STATUS: 0 -------- CASE: builtin_bracket [ -t xxx ] ^~~ 'test/runtime-errors.sh':812: (test) Invalid file descriptor 'xxx' [ -t '' ] ^ 'test/runtime-errors.sh':813: (test) Invalid file descriptor '' [ zz -eq 0 ] ^~ 'test/runtime-errors.sh':815: (test) Invalid integer constant 'zz' STATUS: 0 -------- CASE: builtin_builtin builtin ls ^~ 'test/runtime-errors.sh':823: 'ls' isn't a shell builtin STATUS: 0 -------- CASE: builtin_source source ^~~~~~ 'test/runtime-errors.sh':827: 'source' missing required argument source $bad ^~~~ 'test/runtime-errors.sh':830: source '/nonexistent/path' failed: No such file or directory STATUS: 0 -------- CASE: builtin_cd cd ^~ 'test/runtime-errors.sh':835: $HOME isn't defined cd ^~ 'test/runtime-errors.sh':841: $HOME should be a string cd - ^~ 'test/runtime-errors.sh':846: $OLDPWD isn't defined ( cd /nonexistent ^~~~~~~~~~~~ 'test/runtime-errors.sh':849: cd '/nonexistent': No such file or directory STATUS: 0 -------- CASE: builtin_pushd pushd /nonexistent ^~~~~~~~~~~~ 'test/runtime-errors.sh':854: pushd: '/nonexistent': No such file or directory STATUS: 0 -------- CASE: builtin_popd popd # empty dir stack ^~~~ 'test/runtime-errors.sh':858: popd: directory stack is empty ~/git/oilshell/oil/_tmp/runtime-error-popd ~/git/oilshell/oil / ~/git/oilshell/oil/_tmp/runtime-error-popd ~/git/oilshell/oil popd ^~~~ 'test/runtime-errors.sh':866: popd: '/home/andy/git/oilshell/oil/_tmp/runtime-error-popd': No such file or directory STATUS: 0 -------- CASE: builtin_unset unset x a ^ 'test/runtime-errors.sh':874: Can't unset readonly variable 'a' unset -v x a ^ 'test/runtime-errors.sh':875: Can't unset readonly variable 'a' STATUS: 0 -------- CASE: builtin_alias_unalias alias zzz ^~~~~ 'test/runtime-errors.sh':879: No alias named 'zzz' unalias zzz ^~~~~~~ 'test/runtime-errors.sh':880: No alias named 'zzz' STATUS: 0 -------- CASE: builtin_help help zzz ^~~ 'test/runtime-errors.sh':884: no help topics match 'zzz' STATUS: 0 -------- CASE: builtin_trap trap ^~~~ 'test/runtime-errors.sh':888: 'trap' requires a code string trap EXIT ^~~~ 'test/runtime-errors.sh':889: 'trap' requires a signal or hook name trap zzz yyy ^~~ 'test/runtime-errors.sh':891: Invalid signal or hook 'yyy' STATUS: 0 -------- CASE: builtin_getopts getopts ^~~~~~~ 'test/runtime-errors.sh':895: 'getopts' requires an argspec getopts 'a:' ^~~~~~~ 'test/runtime-errors.sh':896: 'getopts' requires the name of a variable to set getopts 'a:' varname ^~~~~~~ 'test/runtime-errors.sh':900: getopts: option '-a' requires an argument. (getopts argv: -a) STATUS: 0 -------- CASE: builtin_wait wait 1234578 ^~~~~~~ 'test/runtime-errors.sh':938: 1234578 isn't a child of this shell STATUS: 0 -------- CASE: builtin_exec exec nonexistent-command 1 2 3 ^~~~~~~~~~~~~~~~~~~ 'test/runtime-errors.sh':942: fatal: exec: 'nonexistent-command' not found STATUS: 0 -------- CASE: strict_word_eval_warnings slice start negative -bc- slice length negative -- slice bad utf-8 [??? no location ???] warning: Invalid start of UTF-8 character -- length bad utf-8 echo ${#s} ^ 'test/runtime-errors.sh':969: warning: Invalid start of UTF-8 character -1 STATUS: 0 -------- CASE: strict_arith_warnings 1 -yy- ^ [ var ? at line 978 of 'test/runtime-errors.sh' ]:1: Unexpected end of input -yy- ^ [ var ? at line 978 of 'test/runtime-errors.sh' ]:1: fatal: Parse error in recursive arithmetic STATUS: 0 -------- CASE: strict_control_flow_warnings break ^~~~~ 'test/runtime-errors.sh':986: fatal: Unexpected 'break' (in function call) STATUS: 0 -------- CASE: control_flow_subshell 1 ( break; echo 'oops') ^~~~~ 'test/runtime-errors.sh':993: Loop and control flow can't be in different processes STATUS: 0 -------- CASE: bool_status if try --allow-status-01 -- myproc; then ^~~~~~~~~~~~~~~~~ 'test/runtime-errors.sh':576: 'try' got invalid flag '--allow-status-01' no match STATUS: 0 -------- CASE: bool_status_simple if try --allow-status-01 -- grep pat BAD; then ^~~~~~~~~~~~~~~~~ 'test/runtime-errors.sh':586: 'try' got invalid flag '--allow-status-01' no match STATUS: 0 -------- CASE: qsn_decode 'no closing quote ^ [ stdin ]:1: Expected closing single quote in QSN string 'foo' trailing data ^~~~~~~~~~~~~~ [ stdin ]:1: Unexpected data after closing quote '\x0' ^ [ stdin ]:1: Unexpected token in QSN string '\u{3bc' ^ [ stdin ]:1: Unexpected token in QSN string 'literal tab' ^ [ stdin ]:1: Unexpected token in QSN string STATUS: 0 -------- CASE: fallback_locations ===== CASE: -c echo hi > / ===== echo hi > / ^ [ -c flag ]:1: Can't open '/': Is a directory ===== CASE: -c s=x; (( s[0] )) ===== s=x; (( s[0] )) ^~ [ -c flag ]:1: fatal: Expected array or assoc in index expression, got value.Str ===== CASE: -c s=x; (( s[0] = 42 )) ===== s=x; (( s[0] = 42 )) ^ [ -c flag ]:1: fatal: Can't assign to items in a string ===== CASE: -c set -u; (( undef )) ===== set -u; (( undef )) ^~~~~ [ -c flag ]:1: fatal: Undefined variable 'undef' ===== CASE: -c (( 3 ** -2 )) ===== (( 3 ** -2 )) ^ [ -c flag ]:1: fatal: Exponent can't be a negative number ===== CASE: -c set -u; [[ $undef =~ . ]] ===== set -u; [[ $undef =~ . ]] ^~~~~~ [ -c flag ]:1: fatal: Undefined variable 'undef' ===== CASE: -c [[ $x =~ $(( 3 ** -2 )) ]] ===== [[ $x =~ $(( 3 ** -2 )) ]] ^ [ -c flag ]:1: fatal: Exponent can't be a negative number ===== CASE: -c type -x ===== type -x ^~ [ -c flag ]:1: 'type' doesn't accept flag -x ===== CASE: -c use x ===== use x ^ [ -c flag ]:1: 'use' expected 'bin' or 'dialect' ===== CASE: -c read --qsn ===== read --qsn ^~~~ [ -c flag ]:1: 'read' --qsn can only be used with --line ===== CASE: -c export -f ===== export -f ^~~~~~ [ -c flag ]:1: 'export' doesn't accept -f because it's dangerous. (The code can usually be restructured with 'source') ===== CASE: -c s=$(true) y=$(( 3 ** -2 )) ===== s=$(true) y=$(( 3 ** -2 )) ^ [ -c flag ]:1: fatal: Exponent can't be a negative number ===== CASE: -c if s=$(true) y=$(( 3 ** -2 )); then echo hi; fi ===== if s=$(true) y=$(( 3 ** -2 )); then echo hi; fi ^ [ -c flag ]:1: fatal: Exponent can't be a negative number ===== CASE: -c shopt -s strict_arith; x=a; echo $(( x )) ===== a ^ [ var ? at line 1 of [ -c flag ] ]:1: fatal: Undefined value in arithmetic context ===== CASE: -c shopt -s strict_arith; x=a; echo $(( $x )) ===== a ^ [ var ? at line 1 of [ -c flag ] ]:1: fatal: Undefined value in arithmetic context ===== CASE: -c shopt -s strict_arith; x=a; [[ $x -gt 3 ]] ===== a ^ [ var ? at line 1 of [ -c flag ] ]:1: fatal: Undefined value in arithmetic context ===== CASE: -c shopt -s strict_arith; shopt -u eval_unsafe_arith; x=a; [[ $x -gt 3 ]] ===== a ^ [ var ? at line 1 of [ -c flag ] ]:1: fatal: Undefined value in arithmetic context ===== CASE: -c shopt -s strict_arith; x=0xgg; echo $(( x )) ===== shopt -s strict_arith; x=0xgg; echo $(( x )) ^ [ -c flag ]:1: fatal: Invalid hex constant '0xgg' done STATUS: 0 -------- CASE: strict_errexit_1 ===== CASE: [strict_errexit] ! { echo 1; echo 2; } ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; ! { echo 1; echo 2; } ===== set -o errexit; shopt -s strict_errexit; ! { echo 1; echo 2; } ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Pipeline). ===== CASE: [strict_errexit] { echo 1; echo 2; } && true ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; { echo 1; echo 2; } && true ===== set -o errexit; shopt -s strict_errexit; { echo 1; echo 2; } && true ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.BraceGroup). ===== CASE: [strict_errexit] { echo 1; echo 2; } || true ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; { echo 1; echo 2; } || true ===== set -o errexit; shopt -s strict_errexit; { echo 1; echo 2; } || true ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.BraceGroup). ===== CASE: [strict_errexit] { echo 1; echo 2; } && true && true ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; { echo 1; echo 2; } && true && true ===== set -o errexit; shopt -s strict_errexit; { echo 1; echo 2; } && true && true ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.BraceGroup). ===== CASE: [strict_errexit] true && { echo 1; echo 2; } || true || true ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; true && { echo 1; echo 2; } || true || true ===== set -o errexit; shopt -s strict_errexit; true && { echo 1; echo 2; } || true || true ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.BraceGroup). ===== CASE: [strict_errexit] true && true && { echo 1; echo 2; } || true || true ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; true && true && { echo 1; echo 2; } || true || true ===== set -o errexit; shopt -s strict_errexit; true && true && { echo 1; echo 2; } || true || true ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.BraceGroup). ===== CASE: [strict_errexit] if { echo 1; echo 2; }; then echo IF; fi ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; if { echo 1; echo 2; }; then echo IF; fi ===== set -o errexit; shopt -s strict_errexit; if { echo 1; echo 2; }; then echo IF; fi ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Sentence). ===== CASE: [strict_errexit] while { echo 1; echo 2; }; do echo WHILE; done ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; while { echo 1; echo 2; }; do echo WHILE; done ===== set -o errexit; shopt -s strict_errexit; while { echo 1; echo 2; }; do echo WHILE; done ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Sentence). ===== CASE: [strict_errexit] until { echo 1; echo 2; }; do echo UNTIL; done ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; until { echo 1; echo 2; }; do echo UNTIL; done ===== set -o errexit; shopt -s strict_errexit; until { echo 1; echo 2; }; do echo UNTIL; done ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Sentence). ===== CASE: [strict_errexit] shopt -s oil:upgrade proc p { echo p } if p { echo hi } ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; shopt -s oil:upgrade proc p { echo p } if p { echo hi } ===== if p { echo hi } ^~ [ -c flag ]:3: errexit was disabled for this construct if p { echo hi } ^ [ -c flag ]:3: fatal: Can't run a proc while errexit is disabled. Use 'try' or wrap it in a process with $0 myproc STATUS: 0 -------- CASE: strict_errexit_conditionals ===== CASE: [strict_errexit] myfunc() { return 1; } while ( myfunc ) do echo yes done ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; myfunc() { return 1; } while ( myfunc ) do echo yes done ===== while ( myfunc ) ^ [ -c flag ]:4: fatal: strict_errexit only allows simple commands in conditionals (got command.Subshell). ===== CASE: [strict_errexit] myfunc() { return 1; } while test "$(myfunc)" != "" do echo yes done ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; myfunc() { return 1; } while test "$(myfunc)" != "" do echo yes done ===== while test "$(myfunc)" != "" ^~ [ -c flag ]:4: fatal: Command subs not allowed here because status wouldn't be checked (strict_errexit) ===== CASE: [strict_errexit] myfunc() { return 1; } if cat <(ls) then echo yes fi ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; myfunc() { return 1; } if cat <(ls) then echo yes fi ===== if cat <(ls) ^~ [ -c flag ]:4: fatal: Process subs not allowed here because status wouldn't be checked (strict_errexit) ===== CASE: [strict_errexit] myfunc() { return 1 } set -o pipefail while myfunc | cat do echo yes done ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; myfunc() { return 1 } set -o pipefail while myfunc | cat do echo yes done ===== while myfunc | cat ^ [ -c flag ]:7: fatal: strict_errexit only allows simple commands in conditionals (got command.Pipeline). ===== CASE: [strict_errexit] myfunc() { return 1 } foo=$(true) # test assignment without proc while bar=$(false) do echo yes done # issue 1007 was caused using command.ShAssignment, rather than the more common # command.Sentence with ; while spam=$(myfunc) do echo yes done ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; myfunc() { return 1 } foo=$(true) # test assignment without proc while bar=$(false) do echo yes done # issue 1007 was caused using command.ShAssignment, rather than the more common # command.Sentence with ; while spam=$(myfunc) do echo yes done ===== while bar=$(false) ^~~~ [ -c flag ]:9: fatal: strict_errexit only allows simple commands in conditionals (got command.ShAssignment). STATUS: 0 -------- CASE: strict_errexit_old ===== CASE: [strict_errexit] if ls | wc -l; then echo Pipeline; fi ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; if ls | wc -l; then echo Pipeline; fi ===== set -o errexit; shopt -s strict_errexit; if ls | wc -l; then echo Pipeline; fi ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Sentence). ===== CASE: [strict_errexit] if ! ls | wc -l; then echo Pipeline; fi ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; if ! ls | wc -l; then echo Pipeline; fi ===== set -o errexit; shopt -s strict_errexit; if ! ls | wc -l; then echo Pipeline; fi ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Sentence). ===== CASE: [strict_errexit] if echo a && echo b; then echo AndOr; fi ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; if echo a && echo b; then echo AndOr; fi ===== set -o errexit; shopt -s strict_errexit; if echo a && echo b; then echo AndOr; fi ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Sentence). ===== CASE: [strict_errexit] ! for x in a; do echo $x; done ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; ! for x in a; do echo $x; done ===== set -o errexit; shopt -s strict_errexit; ! for x in a; do echo $x; done ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Pipeline). ===== CASE: [strict_errexit] _func() { echo; }; ! _func ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; _func() { echo; }; ! _func ===== set -o errexit; shopt -s strict_errexit; _func() { echo; }; ! _func ^ [ -c flag ]:1: errexit was disabled for this construct set -o errexit; shopt -s strict_errexit; _func() { echo; }; ! _func ^~~~~ [ -c flag ]:1: fatal: Can't run a proc while errexit is disabled. Use 'try' or wrap it in a process with $0 myproc ===== CASE: [strict_errexit] ! { echo brace; }; echo "should not get here" ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; ! { echo brace; }; echo "should not get here" ===== set -o errexit; shopt -s strict_errexit; ! { echo brace; }; echo "should not get here" ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Pipeline). ===== CASE: [strict_errexit] ! ( echo subshell ); echo "should not get here" ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; ! ( echo subshell ); echo "should not get here" ===== set -o errexit; shopt -s strict_errexit; ! ( echo subshell ); echo "should not get here" ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Pipeline). ===== CASE: [strict_errexit] ! while false; do echo while; done; echo "should not get here" ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; ! while false; do echo while; done; echo "should not get here" ===== set -o errexit; shopt -s strict_errexit; ! while false; do echo while; done; echo "should not get here" ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Pipeline). ===== CASE: [strict_errexit] ! if true; then false; fi; echo "should not get here" ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; ! if true; then false; fi; echo "should not get here" ===== set -o errexit; shopt -s strict_errexit; ! if true; then false; fi; echo "should not get here" ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Pipeline). ===== CASE: [strict_errexit] ! case x in x) echo x;; esac; echo "should not get here" ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; ! case x in x) echo x;; esac; echo "should not get here" ===== set -o errexit; shopt -s strict_errexit; ! case x in x) echo x;; esac; echo "should not get here" ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Pipeline). ===== CASE: [strict_errexit] ! time echo hi; echo "should not get here" ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; ! time echo hi; echo "should not get here" ===== set -o errexit; shopt -s strict_errexit; ! time echo hi; echo "should not get here" ^ [ -c flag ]:1: fatal: strict_errexit only allows simple commands in conditionals (got command.Pipeline). ===== CASE: [strict_errexit] ! echo $(echo hi); echo "should not get here" ===== ===== CASE: -c set -o errexit; shopt -s strict_errexit; ! echo $(echo hi); echo "should not get here" ===== set -o errexit; shopt -s strict_errexit; ! echo $(echo hi); echo "should not get here" ^~ [ -c flag ]:1: fatal: Command subs not allowed here because status wouldn't be checked (strict_errexit) STATUS: 0 -------- CASE: unset_expr ===== CASE: -c unset -v 1[1] ===== 1[1] ^ [ dynamic place word at line 1 of [ -c flag ] ]:1: fatal: Invalid variable name '1' ===== CASE: -c unset -v 1+2 ===== unset -v 1+2 ^~~~~ [ -c flag ]:1: fatal: Invalid place to modify STATUS: 0 -------- CASE: divzero ===== CASE: -c echo $(( 1 / 0 )) ===== echo $(( 1 / 0 )) ^ [ -c flag ]:1: fatal: Divide by zero ===== CASE: -c echo $(( 1 % 0 )) ===== echo $(( 1 % 0 )) ^ [ -c flag ]:1: fatal: Divide by zero ===== CASE: -c zero=0; echo $(( 1 / zero )) ===== zero=0; echo $(( 1 / zero )) ^~~~ [ -c flag ]:1: fatal: Divide by zero ===== CASE: -c zero=0; echo $(( 1 % zero )) ===== zero=0; echo $(( 1 % zero )) ^~~~ [ -c flag ]:1: fatal: Divide by zero ===== CASE: -c (( a = 1 / 0 )); echo non-fatal; exit 1 ===== (( a = 1 / 0 )); echo non-fatal; exit 1 ^ [ -c flag ]:1: fatal: Divide by zero ===== CASE: -c (( a = 1 % 0 )); echo non-fatal; exit 1 ===== (( a = 1 % 0 )); echo non-fatal; exit 1 ^ [ -c flag ]:1: fatal: Divide by zero ===== CASE: -c set -e; (( a = 1 / 0 )); ===== set -e; (( a = 1 / 0 )); ^ [ -c flag ]:1: fatal: Divide by zero ===== CASE: -c set -e; (( a = 1 % 0 )); ===== set -e; (( a = 1 % 0 )); ^ [ -c flag ]:1: fatal: Divide by zero STATUS: 0 -------- CASE: control_flow break ^~~~~ 'test/runtime-errors.sh':485: warning: Invalid control flow at top level continue ^~~~~~~~ 'test/runtime-errors.sh':486: warning: Invalid control flow at top level SHOULD NOT GET HERE STATUS: 0 -------- CASE: failed_command STATUS: 0 -------- CASE: unsafe_arith_eval 1+ ^ [ var ? at line 1 of [ var ? at line 638 of 'test/runtime-errors.sh' ] ]:1: Unexpected end of input 1+ ^ [ var ? at line 1 of [ var ? at line 638 of 'test/runtime-errors.sh' ] ]:1: fatal: Parse error in recursive arithmetic STATUS: 0 -------- CASE: no_such_command ZZZZZ ^~~~~ 'test/runtime-errors.sh':66: 'ZZZZZ' not found STATUS: 0