-------- CASE: control_flow break ^~~~~ test/runtime-errors.sh:253: warning: Invalid control flow at top level continue ^~~~~~~~ test/runtime-errors.sh:254: warning: Invalid control flow at top level SHOULD NOT GET HERE STATUS: 0 -------- CASE: no_such_command ZZZZZ ^~~~~ test/runtime-errors.sh:57: 'ZZZZZ' not found ZZZZZ ^~~~~ test/runtime-errors.sh:57: fatal: Exiting with status 127 (command in PID 14508) STATUS: 127 -------- CASE: no_such_command_commandsub echo $(ZZZZZ) ^~~~~ test/runtime-errors.sh:64: 'ZZZZZ' not found SHOULD NOT GET HERE STATUS: 0 -------- CASE: no_such_command_heredoc $(ZZZZZ) ^~~~~ test/runtime-errors.sh:76: 'ZZZZZ' not found one three SHOULD NOT GET HERE STATUS: 0 -------- CASE: failed_command false ^~~~~ test/runtime-errors.sh:84: fatal: Exiting with status 1 (command in PID 14515) STATUS: 1 -------- CASE: errexit_usage_error type -z ^~ test/runtime-errors.sh:93: 'type' doesn't accept flag -z type -z ^~~~ test/runtime-errors.sh:93: fatal: Exiting with status 2 (command in PID 14516) STATUS: 2 -------- CASE: errexit_subshell subshell ( echo subshell; exit 42; ) ^ test/runtime-errors.sh:100: fatal: Exiting with status 42 (subshell invoked from PID 14517) STATUS: 42 -------- CASE: errexit_dbracket [[ -n '' ]] ^~ test/runtime-errors.sh:105: fatal: Exiting with status 1 (PID 14519) STATUS: 1 -------- CASE: errexit_alias foo is a alias hi ls: cannot access '/nonexistent': No such file or directory echo hi; ls /nonexistent ^~ [ expansion of alias 'foo' ]:1: fatal: Exiting with status 2 (command in PID 14520) STATUS: 2 -------- CASE: strict_errexit_1 ===== [strict_errexit] ! { echo 1; echo 2; } ===== set -o errexit; shopt -s strict_errexit; ! { echo 1; echo 2; } ^ [ -c flag ]:1: fatal: errexit is disabled here, but strict_errexit disallows it with a compound command (command.BraceGroup) ===== [strict_errexit] { echo 1; echo 2; } && true ===== set -o errexit; shopt -s strict_errexit; { echo 1; echo 2; } && true ^~ [ -c flag ]:1: fatal: errexit is disabled here, but strict_errexit disallows it with a compound command (command.BraceGroup) ===== [strict_errexit] { echo 1; echo 2; } || true ===== set -o errexit; shopt -s strict_errexit; { echo 1; echo 2; } || true ^~ [ -c flag ]:1: fatal: errexit is disabled here, but strict_errexit disallows it with a compound command (command.BraceGroup) ===== [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: errexit is disabled here, but strict_errexit disallows it with a compound command (command.BraceGroup) ===== [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: errexit is disabled here, but strict_errexit disallows it with a compound command (command.BraceGroup) ===== [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: errexit is disabled here, but strict_errexit disallows it with a compound command (command.BraceGroup) ===== [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: errexit is disabled here, but strict_errexit disallows it with a compound command (command.BraceGroup) ===== [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: errexit is disabled here, but strict_errexit disallows it with a compound command (command.BraceGroup) ===== [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: errexit is disabled here, but strict_errexit disallows it with a compound command (command.BraceGroup) STATUS: 0 -------- CASE: strict_errexit_2 ===== [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: errexit is disabled here, but strict_errexit disallows it with a compound command (command.Pipeline) ===== [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: errexit is disabled here, but strict_errexit disallows it with a compound command (command.Pipeline) ===== [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: errexit is disabled here, but strict_errexit disallows it with a compound command (command.DoGroup) ===== [strict_errexit] _func() { echo; }; ! _func ===== set -o errexit; shopt -s strict_errexit; _func() { echo; }; ! _func ^~~~~ [ -c flag ]:1: fatal: can't disable errexit running a function. Maybe wrap the function in a process with the at-splice pattern. ===== [strict_errexit] ! { echo brace; } ===== set -o errexit; shopt -s strict_errexit; ! { echo brace; } ^ [ -c flag ]:1: fatal: errexit is disabled here, but strict_errexit disallows it with a compound command (command.BraceGroup) ===== [strict_errexit] ! ( echo subshell ) ===== set -o errexit; shopt -s strict_errexit; ! ( echo subshell ) ^ [ -c flag ]:1: fatal: errexit is disabled here, but strict_errexit disallows it with a compound command (command.Subshell) ===== [strict_errexit] ! while false; do echo while; done ===== set -o errexit; shopt -s strict_errexit; ! while false; do echo while; done ^ [ -c flag ]:1: fatal: errexit is disabled here, but strict_errexit disallows it with a compound command (command.WhileUntil) ===== [strict_errexit] ! if true; then false; fi ===== set -o errexit; shopt -s strict_errexit; ! if true; then false; fi ^ [ -c flag ]:1: fatal: errexit is disabled here, but strict_errexit disallows it with a compound command (command.If) ===== [strict_errexit] ! case x in x) echo x;; esac ===== set -o errexit; shopt -s strict_errexit; ! case x in x) echo x;; esac ^ [ -c flag ]:1: fatal: errexit is disabled here, but strict_errexit disallows it with a compound command (command.Case) ===== [strict_errexit] ! time echo hi ===== set -o errexit; shopt -s strict_errexit; ! time echo hi ^ [ -c flag ]:1: fatal: errexit is disabled here, but strict_errexit disallows it with a compound command (command.TimeBlock) ===== [strict_errexit] ! echo $(echo hi) ===== hi STATUS: 0 -------- CASE: pipefail 0 false | wc -l ^~~~~ test/runtime-errors.sh:191: fatal: Exiting with status 1 (command in PID 14609) 0 false | wc -l ^ test/runtime-errors.sh:191: fatal: Exiting with status 1 (pipeline invoked from PID 14606) STATUS: 1 -------- CASE: pipefail_group 1 1 3 echo hi | { cat; sh -c 'exit 42'; } | wc ^ test/runtime-errors.sh:213: fatal: Exiting with status 42 (pipeline invoked from PID 14611) STATUS: 42 -------- CASE: pipefail_subshell 1 1 3 echo hi | (cat; sh -c 'exit 42') | wc ^ test/runtime-errors.sh:221: fatal: Exiting with status 42 (pipeline invoked from PID 14616) STATUS: 42 -------- CASE: pipefail_func echo hi | f | wc ^ test/runtime-errors.sh:204: fatal: Exiting with status 42 (command in PID 14623) 1 1 3 echo hi | f | wc ^ test/runtime-errors.sh:204: fatal: Exiting with status 42 (pipeline invoked from PID 14621) STATUS: 42 -------- CASE: pipefail_while sh -c 'exit 42' ^~ test/runtime-errors.sh:233: fatal: Exiting with status 42 (command in PID 14628) 2 6 12 seq 3 | while true; do ^ test/runtime-errors.sh:229: fatal: Exiting with status 42 (pipeline invoked from PID 14626) STATUS: 42 -------- CASE: pipefail_multiple six { echo 'six'; sh -c 'exit 6'; } ^~ test/runtime-errors.sh:248: fatal: Exiting with status 6 (command in PID 14631) { echo 'four'; sh -c 'exit 4'; } | ^ test/runtime-errors.sh:246: fatal: Exiting with status 6 (pipeline invoked from PID 14631) STATUS: 6 -------- CASE: core_process echo foo > not/a/file ^ test/runtime-errors.sh:261: Can't open 'not/a/file': No such file or directory echo foo > /etc/no-perms-for-this ^ test/runtime-errors.sh:262: Can't open '/etc/no-perms-for-this': Permission denied echo hi 1>&3 ^~~ test/runtime-errors.sh:263: 3: Bad file descriptor STATUS: 1 -------- CASE: osh_state HOME=(a b) ^~~~~ test/runtime-errors.sh:269: fatal: Only strings can be exported STATUS: 1 -------- CASE: nounset echo $x ^~ test/runtime-errors.sh:320: fatal: Undefined variable 'x' STATUS: 1 -------- CASE: bad_var_ref echo ${!name} ^~~~ test/runtime-errors.sh:327: fatal: Bad indirect expansion: 'bad var name' STATUS: 1 -------- CASE: nounset_arith echo $(( x )) ^~~~ test/runtime-errors.sh:336: fatal: Undefined variable 'x' STATUS: 1 -------- CASE: divzero echo $(( 1 / 0 )) ^ [ -c flag ]:1: fatal: Divide by zero echo $(( 1 % 0 )) ^ [ -c flag ]:1: fatal: Divide by zero zero=0; echo $(( 1 / zero )) ^~~~ [ -c flag ]:1: fatal: Divide by zero zero=0; echo $(( 1 % zero )) ^~~~ [ -c flag ]:1: fatal: Divide by zero (( a = 1 / 0 )); echo non-fatal; exit 1 ^ [ -c flag ]:1: fatal: Divide by zero (( a = 1 % 0 )); echo non-fatal; exit 1 ^ [ -c flag ]:1: fatal: Divide by zero set -e; (( a = 1 / 0 )); ^ [ -c flag ]:1: fatal: Divide by zero set -e; (( a = 1 % 0 )); ^ [ -c flag ]:1: fatal: Divide by zero STATUS: 0 -------- CASE: array_arith (( a++ )) # doesn't make sense ^ test/runtime-errors.sh:422: fatal: Expected a value convertible to integer, got value.MaybeStrArray STATUS: 1 -------- CASE: undef_arith (( undef[42]++ )) ^~ test/runtime-errors.sh:408: fatal: Can't use [] on value of type value.Str STATUS: 1 -------- CASE: undef_arith2 ['2'] STATUS: 0 -------- CASE: undef_assoc_array bar STATUS: 0 -------- CASE: unsafe_arith_eval shopt -s unsafe_arith_eval ^~~~~ test/runtime-errors.sh:357: 'shopt' got invalid option 'unsafe_arith_eval' 0 STATUS: 0 -------- CASE: unset_expr shopt -s unsafe_arith_eval ^~~~~ test/runtime-errors.sh:365: 'shopt' got invalid option 'unsafe_arith_eval' 1[1] ^ (source.ArgvWord word_spid:4):1: The [ operator doesn't apply to this expression unset -v 1[1] ^ [ -c flag ]:1: 'unset' Invalid unset expression Expected status 1, got 2 STATUS: 1 -------- CASE: string_to_int_arith 5 echo $(( x + 5 )) ^ test/runtime-errors.sh:378: fatal: Invalid integer constant 'ZZZ' STATUS: 1 -------- 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 -eq 0 ]] ^ test/runtime-errors.sh:462: fatal: Invalid integer constant 'a' STATUS: 1 -------- CASE: string_as_array foo echo "${str[@]}" ^~ test/runtime-errors.sh:526: fatal: Can't index string with @ STATUS: 1 -------- CASE: array_assign_1 s[0]=x # can't assign value ^~ test/runtime-errors.sh:498: fatal: Can't assign to items in a string STATUS: 1 -------- CASE: array_assign_2 array[0]=x ^~~~~~ test/runtime-errors.sh:503: fatal: Can't assign to readonly array STATUS: 1 -------- CASE: readonly_assign x=2 ^~ test/runtime-errors.sh:508: fatal: Can't assign to readonly value 'x' STATUS: 1 -------- CASE: multiple_assign a=1 b=2 x=42 ^~ test/runtime-errors.sh:514: fatal: Can't assign to readonly value 'x' STATUS: 1 -------- CASE: multiple_assign_2 0 STATUS: 0 -------- CASE: patsub_bad_glob echo ${x//[^]} ^ test/runtime-errors.sh:448: fatal: Error matching regex '([^])': Invalid regex syntax (func_regex_first_group_match) STATUS: 1 -------- CASE: builtin_bracket [ -t xxx ] ^~~ test/runtime-errors.sh:535: (test) Invalid file descriptor 'xxx' STATUS: 2 -------- CASE: builtin_builtin builtin ls ^~ test/runtime-errors.sh:540: 'ls' isn't a shell builtin STATUS: 1 -------- CASE: builtin_source source ^~~~~~ test/runtime-errors.sh:544: 'source' missing required argument source $bad ^~~~ test/runtime-errors.sh:547: source '/nonexistent/path' failed: No such file or directory STATUS: 1 -------- CASE: builtin_cd cd ^~ test/runtime-errors.sh:552: $HOME isn't defined cd ^~ test/runtime-errors.sh:558: $HOME shouldn't be an array cd - ^~ test/runtime-errors.sh:563: $OLDPWD not set ( cd /nonexistent ^~~~~~~~~~~~ test/runtime-errors.sh:566: cd '/nonexistent': No such file or directory STATUS: 1 -------- CASE: builtin_pushd pushd /nonexistent ^~~~~~~~~~~~ test/runtime-errors.sh:571: pushd: '/nonexistent': No such file or directory STATUS: 1 -------- CASE: builtin_popd popd # empty dir stack ^~~~ test/runtime-errors.sh:575: 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:583: popd: '/home/andy/git/oilshell/oil/_tmp/runtime-error-popd': No such file or directory STATUS: 1 -------- CASE: builtin_unset unset x a ^ test/runtime-errors.sh:591: Can't unset readonly variable 'a' unset -v x a ^ test/runtime-errors.sh:592: Can't unset readonly variable 'a' STATUS: 1 -------- CASE: builtin_alias_unalias alias zzz ^~~ test/runtime-errors.sh:596: No alias named 'zzz' unalias zzz ^~~ test/runtime-errors.sh:597: No alias named 'zzz' STATUS: 1 -------- CASE: builtin_help help zzz ^~~ test/runtime-errors.sh:601: no help topics match 'zzz' STATUS: 1 -------- CASE: builtin_trap trap ^~~~ test/runtime-errors.sh:605: 'trap' requires a code string trap EXIT ^~~~ test/runtime-errors.sh:606: 'trap' requires a signal or hook name trap zzz yyy ^~~ test/runtime-errors.sh:608: Invalid signal or hook 'yyy' STATUS: 1 -------- CASE: builtin_getopts getopts ^~~~~~~ test/runtime-errors.sh:612: 'getopts' requires an argspec getopts 'a:' ^~~~~~~ test/runtime-errors.sh:613: 'getopts' requires the name of a variable to set getopts 'a:' varname ^~~~~~~ test/runtime-errors.sh:617: getopts: option '-a' requires an argument. (getopts argv: -a) STATUS: 0 -------- CASE: builtin_wait wait 1234578 ^~~~~~~ test/runtime-errors.sh:631: 1234578 isn't a child of this shell STATUS: 127 -------- CASE: builtin_exec exec nonexistent-command 1 2 3 ^~~~~~~~~~~~~~~~~~~ test/runtime-errors.sh:635: exec: 'nonexistent-command' not found STATUS: 127 -------- CASE: strict_word_eval_warnings slice start negative echo -${s: -2}- ^~ test/runtime-errors.sh:648: warning: The start index of a string slice can't be negative: -2 -- slice length negative echo -${s: 1: -2}- ^~ test/runtime-errors.sh:652: warning: The length of a string slice can't be negative: -2 -- slice bad utf-8 [??? no location ???] warning: Invalid start of UTF-8 character -- length bad utf-8 echo ${#s} ^ test/runtime-errors.sh:662: warning: Invalid start of UTF-8 character -1 STATUS: 0 -------- CASE: strict_arith_warnings 1 1 done STATUS: 0 -------- CASE: strict_control_flow_warnings break ^~~~~ test/runtime-errors.sh:679: fatal: Unexpected 'break' (in function call) STATUS: 1 -------- CASE: control_flow_subshell 1 ( break; echo 'oops') ^~~~~ test/runtime-errors.sh:686: Loop and control flow can't be in different processes ( break; echo 'oops') ^ test/runtime-errors.sh:686: fatal: Exiting with status 1 (subshell invoked from PID 14725) STATUS: 1