-------- 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 an alias for "echo hi; ls " 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 10108: command.Simple failed with status 127 --------------------------- echo hi > "" ^ [ -c flag ]:1: Can't open '': No such file or directory [ -c flag ]:1: errexit PID 10111: 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 10114: 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 10117: 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 10124: command.Simple failed with status 126 ls: cannot access '/x': No such file or directory ls /x; echo $? ^~ [ -c flag ]:1: errexit PID 10128: 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 10132: 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 10139: 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 10142: command.Simple failed with status 1 --------------------------- [[ 0 -eq 1 ]] ^~ [ -c flag ]:1: errexit PID 10145: 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 10156: command.Simple failed with status 1 [ -c flag ]:1: errexit PID 10152: Command Sub exited with status 1 --------------------------- ls | false | wc -l ^~~~~ [ -c flag ]:1: errexit PID 10161: command.Simple failed with status 1 0 --------------------------- ls | { echo hi; ( exit 42 ); } | wc -l; echo ^ [ -c flag ]:1: errexit PID 10166: command.Subshell failed with status 42 1 ls | { echo hi; ( exit 42 ); } | wc -l; echo ^ [ -c flag ]:1: errexit PID 10162: command.Pipeline failed with status 42 --------------------------- { false; wc -l; } ^~~~~ [ -c flag ]:2: errexit PID 10169: command.Simple failed with status 1 { echo one; ( exit 42 ); } |\ ^ [ -c flag ]:1: errexit PID 10172: command.Subshell failed with status 42 { false; wc -l; } ^ [ -c flag ]:2: errexit PID 10169: command.Pipeline failed with status 1 --------------------------- { ls; false; } \ ^~~~~ [ -c flag ]:1: errexit PID 10177: command.Simple failed with status 1 75 { ls; false; } \ ^ [ -c flag ]:1: errexit PID 10174: command.Pipeline failed with status 1 --------------------------- { ls; ( false; true ); } | wc -l; echo hi ^~~~~ [ -c flag ]:1: errexit PID 10186: command.Simple failed with status 1 { ls; ( false; true ); } | wc -l; echo hi ^ [ -c flag ]:1: errexit PID 10183: command.Subshell failed with status 1 75 { ls; ( false; true ); } | wc -l; echo hi ^ [ -c flag ]:1: errexit PID 10180: command.Pipeline failed with status 1 --------------------------- ls <(sort YY) <(zz); echo hi ^~ [ -c flag ]:1: 'zz' not found [ -c flag ]:1: errexit PID 10191: 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 10187: 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 10193: 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 10201: command.Simple failed with status 127 [ -c flag ]:1: errexit PID 10198: command.Simple failed with status 127 yy | zz ^~ [ -c flag ]:1: errexit PID 10198: command.Pipeline failed with status 127 --------------------------- echo $([[ 0 -eq 1 ]]) ^~ [ -c flag ]:1: errexit PID 10205: command.DBracket failed with status 1 [ -c flag ]:1: errexit PID 10202: Command Sub exited with status 1 --------------------------- var y = $([[ 0 -eq 1 ]]) ^~ [ -c flag ]:1: errexit PID 10209: command.DBracket failed with status 1 [ -c flag ]:1: errexit PID 10206: 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 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:806: 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 ===== CASE: -c readonly -a array=(1 2 3); array[0]=x ===== readonly -a array=(1 2 3); array[0]=x ^~~~~~ [ -c flag ]:1: fatal: Can't assign to readonly array ===== CASE: -c readonly -a array=(1 2 3); export array ===== readonly -a array=(1 2 3); export array ^~~~~ [ -c flag ]:1: fatal: Only strings can be exported STATUS: 0 -------- CASE: readonly_assign ===== CASE: -c readonly x=1; x=2 ===== readonly x=1; x=2 ^~ [ -c flag ]:1: fatal: Can't assign to readonly value 'x' ===== CASE: -c readonly x=2; y=3 x=99 ===== readonly x=2; y=3 x=99 ^~ [ -c flag ]:1: fatal: Can't assign to readonly value 'x' ===== CASE: -c readonly x=2; declare x=99 ===== readonly x=2; declare x=99 ^~ [ -c flag ]:1: fatal: Can't assign to readonly value 'x' ===== CASE: -c readonly x=2; export x=99 ===== readonly x=2; export x=99 ^~ [ -c flag ]:1: fatal: Can't assign to readonly value 'x' STATUS: 0 -------- CASE: multiple_assign a=1 b=2 x=42 ^~ test/runtime-errors.sh:794: 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:817: (test) Invalid file descriptor 'xxx' [ -t '' ] ^ test/runtime-errors.sh:818: (test) Invalid file descriptor '' [ zz -eq 0 ] ^~ test/runtime-errors.sh:820: (test) Invalid integer constant 'zz' STATUS: 0 -------- CASE: builtin_builtin builtin ls ^~ test/runtime-errors.sh:828: 'ls' isn't a shell builtin STATUS: 0 -------- CASE: builtin_source source ^~~~~~ test/runtime-errors.sh:832: 'source' missing required argument source $bad ^~~~ test/runtime-errors.sh:835: source '/nonexistent/path' failed: No such file or directory STATUS: 0 -------- CASE: builtin_cd cd ^~ test/runtime-errors.sh:840: $HOME isn't defined cd ^~ test/runtime-errors.sh:846: $HOME should be a string cd - ^~ test/runtime-errors.sh:851: $OLDPWD isn't defined ( cd /nonexistent ^~~~~~~~~~~~ test/runtime-errors.sh:854: cd '/nonexistent': No such file or directory STATUS: 0 -------- CASE: builtin_pushd pushd /nonexistent ^~~~~~~~~~~~ test/runtime-errors.sh:859: pushd: '/nonexistent': No such file or directory STATUS: 0 -------- CASE: builtin_popd popd # empty dir stack ^~~~ test/runtime-errors.sh:863: 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:871: 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:879: Can't unset readonly variable 'a' unset -v x a ^ test/runtime-errors.sh:880: Can't unset readonly variable 'a' STATUS: 0 -------- CASE: builtin_alias_unalias alias zzz ^~~~~ test/runtime-errors.sh:884: No alias named 'zzz' unalias zzz ^~~~~~~ test/runtime-errors.sh:885: No alias named 'zzz' STATUS: 0 -------- CASE: builtin_help help zzz ^~~ test/runtime-errors.sh:889: no help topics match 'zzz' STATUS: 0 -------- CASE: builtin_trap trap ^~~~ test/runtime-errors.sh:893: 'trap' requires a code string trap EXIT ^~~~ test/runtime-errors.sh:894: 'trap' requires a signal or hook name trap zzz yyy ^~~ test/runtime-errors.sh:896: Invalid signal or hook 'yyy' STATUS: 0 -------- CASE: builtin_getopts getopts ^~~~~~~ test/runtime-errors.sh:900: 'getopts' requires an argspec getopts 'a:' ^~~~~~~ test/runtime-errors.sh:901: 'getopts' requires the name of a variable to set getopts 'a:' varname ^~~~~~~ test/runtime-errors.sh:905: getopts: option '-a' requires an argument. (getopts argv: -a) STATUS: 0 -------- CASE: builtin_wait wait 1234578 ^~~~~~~ test/runtime-errors.sh:943: 1234578 isn't a child of this shell STATUS: 0 -------- CASE: builtin_exec exec nonexistent-command 1 2 3 ^~~~~~~~~~~~~~~~~~~ test/runtime-errors.sh:947: 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:974: warning: Invalid start of UTF-8 character -1 STATUS: 0 -------- CASE: strict_arith_warnings 1 -yy- ^ [ var ? at line 983 of test/runtime-errors.sh ]:1: Unexpected end of input -yy- ^ [ var ? at line 983 of test/runtime-errors.sh ]:1: fatal: Parse error in recursive arithmetic STATUS: 0 -------- CASE: strict_control_flow_warnings break ^~~~~ test/runtime-errors.sh:991: fatal: Unexpected 'break' (in proc call) STATUS: 0 -------- CASE: control_flow_subshell 1 ( break; echo 'oops') ^~~~~ test/runtime-errors.sh:998: 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: 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 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 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 LHS 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 LHS 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