ninja: no work to do.

///
/// Runtime errors - Unquoted test functions
///


===== TEST function: unquoted-ambiguous_redirect =====

    echo foo > "$@"
               ^
test/runtime-errors.sh:546: Can't redirect to zero files
ambiguous redirect not fatal unless errexit
    echo foo > "$@"
               ^
test/runtime-errors.sh:550: Can't redirect to zero files
----- STATUS: 0


===== TEST function: unquoted-ambiguous_redirect_context =====

    echo $(echo hi > "$@")
                     ^
test/runtime-errors.sh:563: Can't redirect to zero files

ambiguous is NOT FATAL in command sub

    foo=$(echo hi > "$@")
                    ^
test/runtime-errors.sh:567: Can't redirect to zero files

ambiguous is NOT FATAL in assignment in command sub

    echo $(echo hi > "$@")
                     ^
test/runtime-errors.sh:575: Can't redirect to zero files

ambiguous is NOT FATAL in command sub, even if errexit

But when the command sub is in an assignment, it is fatal
    foo=$(echo hi > "$@")
                    ^
test/runtime-errors.sh:582: Can't redirect to zero files
----- STATUS: 0


===== TEST function: unquoted-array_arith =====

2 2
----- STATUS: 0


===== TEST function: unquoted-array_assign_1 =====

    s[0]=x  # can't assign value
    ^~
test/runtime-errors.sh:864: fatal: Can't assign to items in a string
----- STATUS: 0


===== TEST function: unquoted-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 =====



test/runtime-errors.sh: fatal: Should FAIL under _bin/cxx-asan/osh: expected status 1, got 0
----- STATUS: 0


===== TEST function: unquoted-bad_file_descriptor =====

F_GETFD fd 7: Bad file descriptor
test/runtime-errors.sh:588: I/O error applying redirect: Bad file descriptor
----- STATUS: 0


===== TEST function: unquoted-bad_var_ref =====

  bad var name
     ^
[ contents of var 'name' at line 649 of test/runtime-errors.sh ]:1: Expected end of var ref expression
    echo ${!name}
            ^~~~
test/runtime-errors.sh:649: Invalid var ref expression
----- STATUS: 0


===== TEST function: unquoted-bool_status =====

    if try --allow-status-01 -- myproc; then
           ^~~~~~~~~~~~~~~~~
test/runtime-errors.sh:619: 'try' got invalid flag '--allow-status-01'
no match
----- STATUS: 0


===== TEST function: unquoted-bool_status_simple =====

    if try --allow-status-01 -- grep pat BAD; then
           ^~~~~~~~~~~~~~~~~
test/runtime-errors.sh:629: 'try' got invalid flag '--allow-status-01'
no match
----- STATUS: 0


===== TEST function: unquoted-builtin_alias_unalias =====

    alias zzz
    ^~~~~
test/runtime-errors.sh:975: No alias named 'zzz'
    unalias zzz
    ^~~~~~~
test/runtime-errors.sh:976: No alias named 'zzz'
----- STATUS: 0


===== TEST function: unquoted-builtin_bracket =====

    [ -t xxx ]
         ^~~
test/runtime-errors.sh:908: (test) Invalid file descriptor 'xxx'
    [ -t '' ]
         ^
test/runtime-errors.sh:909: (test) Invalid file descriptor ''
    [ zz -eq 0 ]
      ^~
test/runtime-errors.sh:911: (test) Invalid integer 'zz'
----- STATUS: 0


===== TEST function: unquoted-builtin_builtin =====

    builtin ls
            ^~
test/runtime-errors.sh:919: 'ls' isn't a shell builtin
----- STATUS: 0


===== TEST function: unquoted-builtin_cd =====

      cd
      ^~
test/runtime-errors.sh:931: cd got no argument, and $HOME isn't set
      cd
      ^~
test/runtime-errors.sh:937: cd got no argument, and $HOME isn't set
      cd -
      ^~
test/runtime-errors.sh:942: $OLDPWD isn't defined
    ( cd /nonexistent
         ^
test/runtime-errors.sh:945: cd '/nonexistent': No such file or directory
----- STATUS: 0


===== TEST function: unquoted-builtin_exec =====

    exec nonexistent-command 1 2 3
         ^~~~~~~~~~~~~~~~~~~
test/runtime-errors.sh:1038: fatal: exec: 'nonexistent-command' not found
----- STATUS: 0


===== TEST function: unquoted-builtin_getopts =====

    getopts
    ^~~~~~~
test/runtime-errors.sh:991: 'getopts' requires an argspec
    getopts 'a:'
    ^~~~~~~
test/runtime-errors.sh:992: 'getopts' requires the name of a variable to set
    getopts 'a:' varname
    ^~~~~~~
test/runtime-errors.sh:996: getopts: option '-a' requires an argument.
(getopts argv: -a)
----- STATUS: 0


===== TEST function: unquoted-builtin_help =====

    help zzz
         ^~~
test/runtime-errors.sh:980: no help topics match 'zzz'
----- STATUS: 0


===== TEST function: unquoted-builtin_popd =====

    popd  # empty dir stack
    ^~~~
test/runtime-errors.sh:954: popd: directory stack is empty
~/oil/_tmp/runtime-error-popd ~/oil
/ ~/oil/_tmp/runtime-error-popd ~/oil
      popd
      ^~~~
test/runtime-errors.sh:962: popd: '/home/uke/oil/_tmp/runtime-error-popd': No such file or directory
----- STATUS: 0


===== TEST function: unquoted-builtin_pushd =====

    pushd /nonexistent
          ^
test/runtime-errors.sh:950: pushd: '/nonexistent': No such file or directory
----- STATUS: 0


===== TEST function: unquoted-builtin_source =====

    source
    ^~~~~~
test/runtime-errors.sh:923: 'source' requires a file path
    source $bad
           ^~~~
test/runtime-errors.sh:926: source '/nonexistent/path' failed: No such file or directory
----- STATUS: 0


===== TEST function: unquoted-builtin_trap =====

    trap
    ^~~~
test/runtime-errors.sh:984: 'trap' requires a code string
    trap EXIT
    ^~~~
test/runtime-errors.sh:985: 'trap' requires a signal or hook name
    trap zzz yyy
             ^~~
test/runtime-errors.sh:987: Invalid signal or hook 'yyy'
----- STATUS: 0


===== TEST function: unquoted-builtin_unset =====

    unset x a
            ^
test/runtime-errors.sh:970: Can't unset readonly variable 'a'
    unset -v x a
               ^
test/runtime-errors.sh:971: Can't unset readonly variable 'a'
----- STATUS: 0


===== TEST function: unquoted-builtin_wait =====

    wait 1234578
         ^~~~~~~
test/runtime-errors.sh:1034: 1234578 isn't a child of this shell
----- STATUS: 0


===== TEST function: unquoted-command_sub_errexit =====

----- STATUS: 0


===== TEST function: unquoted-multiple_assign =====

    a=1 b=2 x=42
            ^~
test/runtime-errors.sh:885: fatal: Can't assign to readonly value 'x'
----- STATUS: 0


===== TEST function: unquoted-multiple_assign_2 =====

0
----- STATUS: 0


===== TEST function: unquoted-no_such_command_heredoc =====

  $(ZZZZZ)
    ^~~~~
test/runtime-errors.sh:101: 'ZZZZZ' not found (OILS-ERR-100)
one

three
SHOULD NOT GET HERE
----- STATUS: 0


===== TEST function: unquoted-nounset =====

    echo $x
         ^~
test/runtime-errors.sh:642: fatal: Undefined variable 'x'
----- STATUS: 0


===== TEST function: unquoted-nounset_arith =====

    echo $(( x ))
             ^
test/runtime-errors.sh:658: fatal: Undefined variable 'x'
----- STATUS: 0


===== TEST function: unquoted-patsub_bad_glob =====

    echo ${x//[^]}
            ^
test/runtime-errors.sh:814: fatal: Error matching regex '([^])': Invalid regex syntax (func_regex_first_group_match)
----- STATUS: 0


===== TEST function: unquoted-pipefail =====

0
0
----- STATUS: 0


===== TEST function: unquoted-pipefail_func =====

      1       1       3
----- STATUS: 0


===== TEST function: unquoted-pipefail_group =====

      1       1       3
----- STATUS: 0


===== TEST function: unquoted-pipefail_multiple =====

six
----- STATUS: 0


===== TEST function: unquoted-pipefail_no_words =====

    seq 3 | wc -l | > /nonexistent
                    ^
test/runtime-errors.sh:447: Can't open '/nonexistent': Permission denied
test/runtime-errors.sh:447: I/O error applying redirect: Permission denied
----- STATUS: 0


===== TEST function: unquoted-pipefail_subshell =====

      1       1       3
----- STATUS: 0


===== TEST function: unquoted-pipefail_while =====

      2       6      12
----- STATUS: 0


===== TEST function: unquoted-process_sub_fail =====

a
b
----- STATUS: 0


===== TEST function: unquoted-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


===== TEST function: unquoted-strict_arith_warnings =====

1
  -yy-
      ^
test/runtime-errors.sh:1: Unexpected end of input
  -yy-
      ^
test/runtime-errors.sh:1: fatal: Parse error in recursive arithmetic
----- STATUS: 0


===== TEST function: unquoted-strict_array =====

    echo foo > _tmp/"$@"
               ^~~~
test/runtime-errors.sh:834: Can't redirect to more than one file
    echo foo > _tmp/"$@"
               ^~~~
test/runtime-errors.sh:836: Can't redirect to more than one file
----- STATUS: 0


===== TEST function: unquoted-strict_array_2 =====

    local foo="$@"
              ^
test/runtime-errors.sh:842: fatal: This word should yield a string, but it contains an array
----- STATUS: 0


===== TEST function: unquoted-strict_array_3 =====

    local foo=${1:- "[$@]" }
              ^~
test/runtime-errors.sh:848: fatal: This word should yield a string, but it contains an array
----- STATUS: 0


===== TEST function: unquoted-strict_array_4 =====

x[42] = 99
----- STATUS: 0


===== TEST function: unquoted-strict_word_eval_warnings =====

slice start negative
-bc-
slice length negative
--
slice bad utf-8
[??? no location ???] warning: UTF-8 decode: Bad encoding at offset 0 in string of 6 bytes
--
length bad utf-8
    echo ${#s}
            ^
test/runtime-errors.sh:1065: warning: UTF-8 decode: Bad encoding at offset 0 in string of 6 bytes
-1
----- STATUS: 0


===== TEST function: unquoted-string_as_array =====

foo
foo
----- STATUS: 0


===== TEST function: unquoted-string_to_hex =====

    echo $(( 0xGG + 1 ))
             ^
test/runtime-errors.sh:713: fatal: Invalid integer constant '0xGG'
----- STATUS: 0


===== TEST function: unquoted-string_to_int_arith =====

5
  ZZZ
  ^~~
test/runtime-errors.sh:1: fatal: Undefined value in arithmetic context
----- STATUS: 0


===== TEST function: unquoted-string_to_int_bool =====

  a
  ^
test/runtime-errors.sh:1: fatal: Undefined value in arithmetic context
----- STATUS: 0


===== TEST function: unquoted-string_to_intbase =====

0
SHOULD NOT GET HERE
----- STATUS: 0


===== TEST function: unquoted-string_to_octal =====

    echo $(( 018 + 1 ))
             ^~~
test/runtime-errors.sh:720: fatal: Invalid integer constant '018'
----- STATUS: 0


===== TEST function: unquoted-undef-assoc-array =====

bar
['bar', '11']
['bar', '16']
----- STATUS: 0


===== TEST function: unquoted-undef_arith =====

    (( undef[42]++ ))
    ^~
test/runtime-errors.sh:736: fatal: Can't use [] on value of type Str
----- STATUS: 0


===== TEST function: unquoted-undef_arith2 =====

['2']
----- STATUS: 0


test/runtime-errors.sh: 53 unquoted functions run.  TODO: migrate to test-* to assert status

///
/// Runtime errors - test functions
///

*** Running test-FAIL

===== CASE: -c echo hi > /zzz =====


  echo hi > /zzz
          ^
[ -c flag ]:1: Can't open '/zzz': Permission denied
[ -c flag ]:1: I/O error applying redirect: Permission denied
OK  test-FAIL
*** Running test-arith-ops-str

===== CASE: -c = "100" + "10a" =====


  = "100" + "10a"
          ^
[ -c flag ]:1: fatal: Binary operator expected numbers, got Str and Str (OILS-ERR-201)

===== CASE: -c = "100" - "10a" =====


  = "100" - "10a"
          ^
[ -c flag ]:1: fatal: Binary operator expected numbers, got Str and Str (OILS-ERR-201)

===== CASE: -c = "100" * "10a" =====


  = "100" * "10a"
          ^
[ -c flag ]:1: fatal: Binary operator expected numbers, got Str and Str (OILS-ERR-201)

===== CASE: -c = "100" / "10a" =====


  = "100" / "10a"
          ^
[ -c flag ]:1: fatal: Binary operator expected numbers, got Str and Str (OILS-ERR-201)

===== CASE: -c var a = "100"; setvar a += "10a" =====


  var a = "100"; setvar a += "10a"
                          ^~
[ -c flag ]:1: fatal: Binary operator expected numbers, got Str and Str (OILS-ERR-201)

===== CASE: -c var a = "100"; setvar a -= "10a" =====


  var a = "100"; setvar a -= "10a"
                          ^~
[ -c flag ]:1: fatal: Binary operator expected numbers, got Str and Str (OILS-ERR-201)

===== CASE: -c var a = "100"; setvar a *= "10a" =====


  var a = "100"; setvar a *= "10a"
                          ^~
[ -c flag ]:1: fatal: Binary operator expected numbers, got Str and Str (OILS-ERR-201)

===== CASE: -c var a = "100"; setvar a /= "10a" =====


  var a = "100"; setvar a /= "10a"
                          ^~
[ -c flag ]:1: fatal: Binary operator expected numbers, got Str and Str (OILS-ERR-201)

===== CASE: -c = "age: " + "100" =====


  = "age: " + "100"
            ^
[ -c flag ]:1: fatal: Binary operator expected numbers, got Str and Str (OILS-ERR-201)

===== CASE: -c var myvar = "a string"
= 100 + myvar =====


  = 100 + myvar
        ^
[ -c flag ]:2: fatal: Binary operator expected numbers, got Int and Str (OILS-ERR-201)
OK  test-arith-ops-str
*** Running test-assoc-array

===== CASE: -c declare -A assoc; assoc[x]=1 =====


  declare -A assoc; assoc[x]=1
                    ^~~~~~
[ -c flag ]:1: fatal: Assoc array keys must be strings: $x 'x' "$x" etc. (OILS-ERR-101)

===== CASE: -c declare -A assoc; assoc[$key]=1 =====



===== CASE: -c declare -A assoc; assoc["x"]=1 =====



===== CASE: -c declare -A assoc; assoc['x']=1 =====



===== CASE: -c declare -A assoc; echo ${assoc[x]} =====


  declare -A assoc; echo ${assoc[x]}
                                 ^
[ -c flag ]:1: fatal: Assoc array keys must be strings: $x 'x' "$x" etc. (OILS-ERR-101)

===== CASE: -c declare -A assoc; echo ${assoc["x"]} =====




===== CASE: -c declare -A assoc; echo ${assoc[$key]} =====




===== CASE: -c declare -A assoc; key=k; unset assoc[$key] =====


  assoc[k]
       ^
[ dynamic LHS at line 1 of [ -c flag ] ]:1

  declare -A assoc; key=k; unset assoc[$key]
                                 ^~~~~~
[ -c flag ]:1: fatal: Assoc array keys must be strings: $x 'x' "$x" etc. (OILS-ERR-101)

===== CASE: -c declare -A assoc; key=k; unset "assoc[$key]" =====


  assoc[k]
       ^
[ dynamic LHS at line 1 of [ -c flag ] ]:1

  declare -A assoc; key=k; unset "assoc[$key]"
                                 ^
[ -c flag ]:1: fatal: Assoc array keys must be strings: $x 'x' "$x" etc. (OILS-ERR-101)

===== CASE: -c declare -A assoc; key=k; unset "assoc[$key]" =====


  assoc[k]
       ^
[ dynamic LHS at line 1 of [ -c flag ] ]:1

  declare -A assoc; key=k; unset "assoc[$key]"
                                 ^
[ -c flag ]:1: fatal: Assoc array keys must be strings: $x 'x' "$x" etc. (OILS-ERR-101)

===== CASE: -c declare -A assoc; key=k; unset 'assoc[$key]' =====



===== CASE: -c eval 'declare -A assoc; assoc[x]=1' =====


  declare -A assoc; assoc[x]=1
                    ^~~~~~
[ eval arg at line 1 of [ -c flag ] ]:1

  eval 'declare -A assoc; assoc[x]=1'
  ^~~~
[ -c flag ]:1: fatal: Assoc array keys must be strings: $x 'x' "$x" etc. (OILS-ERR-101)

===== CASE: -c eval 'declare -A assoc; unset "assoc[x]"' =====


  assoc[x]
       ^
[ dynamic LHS at line 1 of [ eval arg at line 1 of [ -c flag ] ] ]:1

  declare -A assoc; unset "assoc[x]"
                          ^
[ eval arg at line 1 of [ -c flag ] ]:1

  eval 'declare -A assoc; unset "assoc[x]"'
  ^~~~
[ -c flag ]:1: fatal: Assoc array keys must be strings: $x 'x' "$x" etc. (OILS-ERR-101)
OK  test-assoc-array
*** Running test-bind

===== CASE: -c bind -x =====


  bind -x
       ^~
[ -c flag ]:1: 'bind' expected argument to '-x'

===== CASE: -c bind -x foo =====



test/runtime-errors.sh: fatal: Should FAIL under _bin/cxx-asan/osh: expected status 1, got 0
FAIL  test-bind