Results for redirect.test.sh

statusoshosh_.pyosh_.cc
pass 53255
ok 110
FAIL 12950
total555555
caseoshosh_.pyosh_.ccdescription
0pass pass FAIL >&
details
1pass FAIL FAIL <&
detailsdetails
2pass FAIL FAIL Leading redirect
detailsdetails
3pass pass FAIL Nonexistent file
details
4pass pass FAIL Redirect in command sub
details
5pass FAIL FAIL Redirect in assignment
detailsdetails
6pass pass FAIL Redirect in function body.
details
7pass pass pass Bad redirects in function body
8pass FAIL FAIL Redirect in function body is evaluated multiple times
detailsdetails
9pass pass FAIL Redirect in function body AND function call
details
10pass pass FAIL Descriptor redirect with spaces
details
11pass FAIL FAIL Filename redirect with spaces
detailsdetails
12pass FAIL FAIL Quoted filename redirect with spaces
detailsdetails
13pass pass pass Descriptor redirect with filename
14pass FAIL FAIL redirect for loop
detailsdetails
15pass pass FAIL redirect subshell
details
16pass pass FAIL Prefix redirect for loop -- not allowed
details
17pass FAIL FAIL Brace group redirect
detailsdetails
18pass FAIL FAIL Redirect echo to stderr, and then redirect all of stdout somewhere.
detailsdetails
19pass FAIL FAIL Redirect in the middle of two assignments
detailsdetails
20pass FAIL FAIL Redirect in the middle of a command
detailsdetails
21pass FAIL FAIL Named file descriptor
detailsdetails
22pass FAIL FAIL Double digit fd (20> file)
detailsdetails
23pass FAIL FAIL : 9> fdleak (OSH regression)
detailsdetails
24pass pass pass : 4>&4 (OSH regression)
25pass pass pass : 3>&3-
26pass FAIL FAIL 3>&- << EOF (OSH regression: fail to restore fds)
detailsdetails
27pass FAIL FAIL Open file on descriptor 3 and write to it many times
detailsdetails
28pass FAIL FAIL Open file on descriptor 4 and write to it many times
detailsdetails
29pass FAIL FAIL Redirect function stdout
detailsdetails
30pass FAIL FAIL Nested function stdout redirect
detailsdetails
31pass pass pass Redirect to empty string
32pass pass FAIL Redirect to file descriptor that's not open
details
33pass FAIL FAIL Open descriptor with exec
detailsdetails
34pass FAIL FAIL Open multiple descriptors with exec
detailsdetails
35FAIL FAIL FAIL >| to clobber
detailsdetailsdetails
36pass FAIL FAIL &> redirects stdout and stderr
detailsdetails
37pass FAIL FAIL 1>&- to close file descriptor
detailsdetails
38pass FAIL FAIL 1>&2- to move file descriptor
detailsdetails
39pass pass FAIL 1>&2- (Bash bug: fail to restore closed fd)
details
40pass FAIL FAIL <> for read/write
detailsdetails
41pass FAIL FAIL <> for read/write named pipes
detailsdetails
42pass FAIL FAIL &>> appends stdout and stderr
detailsdetails
43pass pass FAIL exec redirect then various builtins
details
44pass pass FAIL >$file touches a file
details
45pass pass FAIL $(< $file) yields the contents of the file
details
46pass pass FAIL $(< file) with more statements
details
47pass pass FAIL < file in pipeline and subshell doesn't work
details
48pass pass FAIL 2>&1 with no command
details
49pass pass FAIL 2&>1 (is it a redirect or is it like a&>1)
details
50ok ok FAIL can't mention big file descriptor
detailsdetailsdetails
51pass pass FAIL : >/dev/null 2> / (OSH regression: fail to pop fd frame)
details
52pass pass FAIL echo foo >&100 (OSH regression: does not fail with invalid fd 100)
details
53pass pass FAIL echo foo >&N where N is first unused fd
details
54pass FAIL FAIL exec {fd}>&- (OSH regression: fails to close fd)
detailsdetails
83 passed, 2 OK, 0 not implemented, 0 BUG, 80 failed, 0 timeouts, 0 cases skipped
1 failed under osh

Details on runs that didn't PASS

osh_.cc0 >&

[osh_.cc stderr] Expected 'hi\n', got "osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.\n"
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py1 <&

[osh_.py stdout] Expected '[foo]\n', got '[]\n'

stdout:
[]
stderr:
  echo foo > $TMP/lessamp.txt
           ^
[ stdin ]:1: Can't open '/lessamp.txt': Permission denied
  exec 6< $TMP/lessamp.txt
       ^~
[ stdin ]:2: Can't open '/lessamp.txt': No such file or directory
  read line <&6
            ^~
[ stdin ]:3: 6: Bad file descriptor
osh_.cc1 <&

[osh_.cc stdout] Expected '[foo]\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py2 Leading redirect

[osh_.py stdout] Expected 'hello\n', got ''
[osh_.py status] Expected 0, got 1

stdout:
stderr: 
  echo hello >$TMP/hello.txt  # temporary fix
             ^
[ stdin ]:1: Can't open '/hello.txt': Permission denied
  <$TMP/hello.txt cat
  ^
[ stdin ]:2: Can't open '/hello.txt': No such file or directory
osh_.cc2 Leading redirect

[osh_.cc stdout] Expected 'hello\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc3 Nonexistent file

[osh_.cc stdout] Expected 'status=1\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc4 Redirect in command sub

[osh_.cc stdout] Expected '\n', got ''
[osh_.cc stderr] Expected 'foo\n', got "osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.\n"
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh_.py5 Redirect in assignment

[osh_.py stdout] Expected 'FILE=\nfoo\nFOO=\n', got 'FILE=\nFOO=\n'

stdout:
FILE=
FOO=
stderr:
  FOO=$(echo foo 1>&2) 2>$TMP/no-command.txt
                       ^~
[ stdin ]:1: Can't open '/no-command.txt': Permission denied
cat: /no-command.txt: No such file or directory
osh_.cc5 Redirect in assignment

[osh_.cc stdout] Expected 'FILE=\nfoo\nFOO=\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc6 Redirect in function body.

[osh_.cc stderr] Expected u'hi\n', got "osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.\n"
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py8 Redirect in function body is evaluated multiple times

[osh_.py stdout] Expected 'i=2\n__\nfile 1\n__\nfile 2\n', got 'i=2\n__\n__\n'
[osh_.py status] Expected 0, got 1

stdout:
i=2
__
__
stderr:
  fun() { echo "file $i"; } 1> "$TMP/file$((i++))"
                            ^~
[ stdin ]:2: Can't open '/file0': Permission denied
  fun() { echo "file $i"; } 1> "$TMP/file$((i++))"
                            ^~
[ stdin ]:2: Can't open '/file1': Permission denied
cat: /file0: No such file or directory
cat: /file1: No such file or directory
osh_.cc8 Redirect in function body is evaluated multiple times

[osh_.cc stdout] Expected 'i=2\n__\nfile 1\n__\nfile 2\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc9 Redirect in function body AND function call

[osh_.cc stdout] Expected u'hi\n', got ''
[osh_.cc stderr] Expected u'', got "osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.\n"
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc10 Descriptor redirect with spaces

[osh_.cc stderr] Expected u'one\ntwo 1\nthree\n', got "osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.\n"
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py11 Filename redirect with spaces

[osh_.py stdout] Expected 'two\n', got ''
[osh_.py status] Expected 0, got 1

stdout:
stderr: 
  echo two 1> $TMP/file-redir1.txt
           ^~
[ stdin ]:1: Can't open '/file-redir1.txt': Permission denied
cat: /file-redir1.txt: No such file or directory
osh_.cc11 Filename redirect with spaces

[osh_.cc stdout] Expected 'two\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py12 Quoted filename redirect with spaces

[osh_.py stdout] Expected 'two 1\n', got ''
[osh_.py status] Expected 0, got 1

stdout:
stderr: 
  echo two \1 > $TMP/file-redir2.txt
              ^
[ stdin ]:1: Can't open '/file-redir2.txt': Permission denied
cat: /file-redir2.txt: No such file or directory
osh_.cc12 Quoted filename redirect with spaces

[osh_.cc stdout] Expected 'two 1\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py14 redirect for loop

[osh_.py stdout] Expected u'1\n2\n3\n', got ''
[osh_.py status] Expected 0, got 1

stdout:
stderr: 
  done > $TMP/redirect-for-loop.txt
       ^
[ stdin ]:4: Can't open '/redirect-for-loop.txt': Permission denied
cat: /redirect-for-loop.txt: No such file or directory
osh_.cc14 redirect for loop

[osh_.cc stdout] Expected u'1\n2\n3\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc15 redirect subshell

[osh_.cc stderr] Expected 'foo\n', got "osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.\n"
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc16 Prefix redirect for loop -- not allowed

[osh_.cc status] Expected 2, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py17 Brace group redirect

[osh_.py stdout] Expected '15\n', got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  { echo block-redirect; } > $TMP/br.txt
                           ^
[ stdin ]:1: Can't open '/br.txt': Permission denied
  cat $TMP/br.txt | wc -c
                    ^~
[ stdin ]:2: 'wc' not found
cat: /br.txt: No such file or directory
osh_.cc17 Brace group redirect

[osh_.cc stdout] Expected '15\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py18 Redirect echo to stderr, and then redirect all of stdout somewhere.

[osh_.py stdout] Expected '10\n', got ''
[osh_.py stderr] Expected 'foo\n', got " { echo foo 1>&2; echo 012345789; } > $TMP/block-stdout.txt\n ^\n[ stdin ]:1: Can't open '/block-stdout.txt': Permission denied\n cat $TMP/block-stdout.txt | wc -c\n ^~\n[ stdin ]:2: 'wc' not found\ncat: /block-stdout.txt: No such file or directory\n"
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  { echo foo 1>&2; echo 012345789; } > $TMP/block-stdout.txt
                                     ^
[ stdin ]:1: Can't open '/block-stdout.txt': Permission denied
  cat $TMP/block-stdout.txt |  wc -c
                               ^~
[ stdin ]:2: 'wc' not found
cat: /block-stdout.txt: No such file or directory
osh_.cc18 Redirect echo to stderr, and then redirect all of stdout somewhere.

[osh_.cc stdout] Expected '10\n', got ''
[osh_.cc stderr] Expected 'foo\n', got "osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.\n"
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py19 Redirect in the middle of two assignments

[osh_.py stdout] Expected u'bar\nfoo\n', got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  FOO=foo >$TMP/out.txt BAR=bar printenv.py FOO BAR
          ^
[ stdin ]:1: Can't open '/out.txt': Permission denied
  tac $TMP/out.txt
  ^~~
[ stdin ]:2: 'tac' not found
osh_.cc19 Redirect in the middle of two assignments

[osh_.cc stdout] Expected u'bar\nfoo\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py20 Redirect in the middle of a command

[osh_.py stdout] Expected u'1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 ', got ''
[osh_.py status] Expected 0, got 1

stdout:
stderr: 
  echo -n 1 2 '3 ' > $f
                   ^
[ stdin ]:2: Can't open '/out': Permission denied
  echo -n 4 5 >> $f '6 '
              ^~
[ stdin ]:3: Can't open '/out': Permission denied
  echo -n 7 >> $f 8 '9 '
            ^~
[ stdin ]:4: Can't open '/out': Permission denied
  echo -n >> $f 1 2 '3 '
          ^~
[ stdin ]:5: Can't open '/out': Permission denied
  echo >> $f -n 4 5 '6 '
       ^~
[ stdin ]:6: Can't open '/out': Permission denied
cat: /out: No such file or directory
osh_.cc20 Redirect in the middle of a command

[osh_.cc stdout] Expected u'1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 ', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py21 Named file descriptor

[osh_.py stdout] Expected 'named-fd-contents\n', got ''
[osh_.py status] Expected 0, got 1

stdout:
stderr: 
  exec {myfd}> $TMP/named-fd.txt
       ^~~~~~~
[ stdin ]:1: Can't open '/named-fd.txt': Permission denied
  echo named-fd-contents >& $myfd
                            ^~~~~
[ stdin ]:2: Redirect descriptor can't be empty
cat: /named-fd.txt: No such file or directory
osh_.cc21 Named file descriptor

[osh_.cc stdout] Expected 'named-fd-contents\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: mycpp/mylib.h:671: V Dict<int, vm::_Builtin *>::index(K) [K = int, V = vm::_Builtin *]: Assertion `0' failed.
osh_.py22 Double digit fd (20> file)

[osh_.py stdout] Expected 'hello20\n', got ''
[osh_.py status] Expected 0, got 1

stdout:
stderr: 
  exec 20> "$TMP/double-digit-fd.txt"
       ^~~
[ stdin ]:1: Can't open '/double-digit-fd.txt': Permission denied
  echo hello20 >&20
               ^~
[ stdin ]:2: 20: Bad file descriptor
cat: /double-digit-fd.txt: No such file or directory
osh_.cc22 Double digit fd (20> file)

[osh_.cc stdout] Expected 'hello20\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py23 : 9> fdleak (OSH regression)

[osh_.py status] Expected 0, got 1

stdout:
stderr: 
  true 9> "$TMP/fd.txt"
       ^~
[ stdin ]:1: Can't open '/fd.txt': Permission denied
  ( echo world >&9 )
               ^~
[ stdin ]:2: 9: Bad file descriptor
cat: /fd.txt: No such file or directory
osh_.cc23 : 9> fdleak (OSH regression)

[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py26 3>&- << EOF (OSH regression: fail to restore fds)

[osh_.py stdout] Expected 'hello\nworld\n', got 'hello\n'
[osh_.py status] Expected 0, got 1
[osh_.py stderr] Found 'Traceback (most recent'

stdout:
hello
stderr:
  exec 3> "$TMP/fd.txt"
       ^~
[ stdin ]:1: Can't open '/fd.txt': Permission denied
Traceback (most recent call last):
  File "/home/andy/git/oilshell/oil/bin/osh_eval.py", line 71, in <module>
    sys.exit(main(sys.argv))
  File "/home/andy/git/oilshell/oil/bin/osh_eval.py", line 39, in main
    status = pure.Main('osh', arg_r, environ, login_shell, loader, None)
  File "/home/andy/git/oilshell/oil/core/pure.py", line 497, in Main
    cmd_flags=cmd_eval.IsMainProgram)
  File "/home/andy/git/oilshell/oil/core/main_loop.py", line 168, in Batch
    is_return, is_fatal = cmd_ev.ExecuteAndCatch(node, cmd_flags=cmd_flags)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 1470, in ExecuteAndCatch
    status = self._Execute(node)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 1317, in _Execute
    status, check_errexit = self._Dispatch(node, pipeline_st)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 626, in _Dispatch
    status = self._RunSimpleCommand(cmd_val, node.do_fork)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 476, in _RunSimpleCommand
    return self.shell_ex.RunSimpleCommand(cmd_val, do_fork)
  File "/home/andy/git/oilshell/oil/core/executor.py", line 188, in RunSimpleCommand
    status = self.RunBuiltin(builtin_id, cmd_val)
  File "/home/andy/git/oilshell/oil/core/executor.py", line 116, in RunBuiltin
    builtin_func = self.builtins[builtin_id]
KeyError: 3
osh_.cc26 3>&- << EOF (OSH regression: fail to restore fds)

[osh_.cc stdout] Expected 'hello\nworld\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py27 Open file on descriptor 3 and write to it many times

[osh_.py stdout] Expected 'hello\nworld\n', got ''
[osh_.py status] Expected 0, got 1
[osh_.py stderr] Found 'Traceback (most recent'

stdout:
stderr: 
  exec 3> "$TMP/fd3.txt"
       ^~
[ stdin ]:1: Can't open '/fd3.txt': Permission denied
Traceback (most recent call last):
  File "/home/andy/git/oilshell/oil/bin/osh_eval.py", line 71, in <module>
    sys.exit(main(sys.argv))
  File "/home/andy/git/oilshell/oil/bin/osh_eval.py", line 39, in main
    status = pure.Main('osh', arg_r, environ, login_shell, loader, None)
  File "/home/andy/git/oilshell/oil/core/pure.py", line 497, in Main
    cmd_flags=cmd_eval.IsMainProgram)
  File "/home/andy/git/oilshell/oil/core/main_loop.py", line 168, in Batch
    is_return, is_fatal = cmd_ev.ExecuteAndCatch(node, cmd_flags=cmd_flags)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 1470, in ExecuteAndCatch
    status = self._Execute(node)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 1317, in _Execute
    status, check_errexit = self._Dispatch(node, pipeline_st)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 626, in _Dispatch
    status = self._RunSimpleCommand(cmd_val, node.do_fork)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 476, in _RunSimpleCommand
    return self.shell_ex.RunSimpleCommand(cmd_val, do_fork)
  File "/home/andy/git/oilshell/oil/core/executor.py", line 188, in RunSimpleCommand
    status = self.RunBuiltin(builtin_id, cmd_val)
  File "/home/andy/git/oilshell/oil/core/executor.py", line 116, in RunBuiltin
    builtin_func = self.builtins[builtin_id]
KeyError: 3
osh_.cc27 Open file on descriptor 3 and write to it many times

[osh_.cc stdout] Expected 'hello\nworld\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py28 Open file on descriptor 4 and write to it many times

[osh_.py stdout] Expected 'hello\nworld\n', got ''
[osh_.py status] Expected 0, got 2

stdout:
stderr: 
  exec 4> "$TMP/fd4.txt"
       ^~
[ stdin ]:1: Can't open '/fd4.txt': Permission denied
  echo hello >&4
             ^~
[ stdin ]:2: 4: Bad file descriptor
  echo world >&4
             ^~
[ stdin ]:3: 4: Bad file descriptor
Error closing descriptor 4: Bad file descriptor
osh I/O error: Bad file descriptor
osh_.cc28 Open file on descriptor 4 and write to it many times

[osh_.cc stdout] Expected 'hello\nworld\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py29 Redirect function stdout

[osh_.py stdout] Expected u'one\ntwo\n', got ''
[osh_.py status] Expected 0, got 1

stdout:
stderr: 
  f > $TMP/redirect-func.txt
    ^
[ stdin ]:2: Can't open '/redirect-func.txt': Permission denied
cat: /redirect-func.txt: No such file or directory
osh_.cc29 Redirect function stdout

[osh_.cc stdout] Expected u'one\ntwo\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py30 Nested function stdout redirect

[osh_.py stdout] Expected u'i1\ni2\n--\no1\no2\n', got '--\n'
[osh_.py status] Expected 0, got 1

stdout:
--
stderr:
  outer > $TMP/outer.txt
        ^
[ stdin ]:10: Can't open '/outer.txt': Permission denied
cat: /inner.txt: No such file or directory
cat: /outer.txt: No such file or directory
osh_.cc30 Nested function stdout redirect

[osh_.cc stdout] Expected u'i1\ni2\n--\no1\no2\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc32 Redirect to file descriptor that's not open

[osh_.cc status] Expected 1, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py33 Open descriptor with exec

[osh_.py stdout] Expected 'hi\n', got ''
[osh_.py status] Expected 0, got 1
[osh_.py stderr] Found 'Traceback (most recent'

stdout:
stderr: 
Traceback (most recent call last):
  File "/home/andy/git/oilshell/oil/bin/osh_eval.py", line 71, in <module>
    sys.exit(main(sys.argv))
  File "/home/andy/git/oilshell/oil/bin/osh_eval.py", line 39, in main
    status = pure.Main('osh', arg_r, environ, login_shell, loader, None)
  File "/home/andy/git/oilshell/oil/core/pure.py", line 497, in Main
    cmd_flags=cmd_eval.IsMainProgram)
  File "/home/andy/git/oilshell/oil/core/main_loop.py", line 168, in Batch
    is_return, is_fatal = cmd_ev.ExecuteAndCatch(node, cmd_flags=cmd_flags)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 1470, in ExecuteAndCatch
    status = self._Execute(node)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 1317, in _Execute
    status, check_errexit = self._Dispatch(node, pipeline_st)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 626, in _Dispatch
    status = self._RunSimpleCommand(cmd_val, node.do_fork)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 476, in _RunSimpleCommand
    return self.shell_ex.RunSimpleCommand(cmd_val, do_fork)
  File "/home/andy/git/oilshell/oil/core/executor.py", line 188, in RunSimpleCommand
    status = self.RunBuiltin(builtin_id, cmd_val)
  File "/home/andy/git/oilshell/oil/core/executor.py", line 116, in RunBuiltin
    builtin_func = self.builtins[builtin_id]
KeyError: 3
osh_.cc33 Open descriptor with exec

[osh_.cc stdout] Expected 'hi\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py34 Open multiple descriptors with exec

[osh_.py stdout] Expected u'three\nfour\n', got ''
[osh_.py status] Expected 0, got 1
[osh_.py stderr] Found 'Traceback (most recent'

stdout:
stderr: 
Traceback (most recent call last):
  File "/home/andy/git/oilshell/oil/bin/osh_eval.py", line 71, in <module>
    sys.exit(main(sys.argv))
  File "/home/andy/git/oilshell/oil/bin/osh_eval.py", line 39, in main
    status = pure.Main('osh', arg_r, environ, login_shell, loader, None)
  File "/home/andy/git/oilshell/oil/core/pure.py", line 497, in Main
    cmd_flags=cmd_eval.IsMainProgram)
  File "/home/andy/git/oilshell/oil/core/main_loop.py", line 168, in Batch
    is_return, is_fatal = cmd_ev.ExecuteAndCatch(node, cmd_flags=cmd_flags)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 1470, in ExecuteAndCatch
    status = self._Execute(node)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 1317, in _Execute
    status, check_errexit = self._Dispatch(node, pipeline_st)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 626, in _Dispatch
    status = self._RunSimpleCommand(cmd_val, node.do_fork)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 476, in _RunSimpleCommand
    return self.shell_ex.RunSimpleCommand(cmd_val, do_fork)
  File "/home/andy/git/oilshell/oil/core/executor.py", line 188, in RunSimpleCommand
    status = self.RunBuiltin(builtin_id, cmd_val)
  File "/home/andy/git/oilshell/oil/core/executor.py", line 116, in RunBuiltin
    builtin_func = self.builtins[builtin_id]
KeyError: 3
osh_.cc34 Open multiple descriptors with exec

[osh_.cc stdout] Expected u'three\nfour\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh35 >| to clobber

[osh stdout] Expected 'status=1\nXX\nZZ\n', got 'status=0\nYY\nZZ\n'

stdout:
status=0
YY
ZZ
stderr:
osh_.py35 >| to clobber

[osh_.py stdout] Expected 'status=1\nXX\nZZ\n', got 'status=1\n'
[osh_.py status] Expected 0, got 1

stdout:
status=1
stderr:
  echo XX >| $TMP/c.txt
          ^~
[ stdin ]:1: Can't open '/c.txt': Permission denied
  echo YY >  $TMP/c.txt  # not globber
          ^
[ stdin ]:3: Can't open '/c.txt': Permission denied
cat: /c.txt: No such file or directory
  echo ZZ >| $TMP/c.txt
          ^~
[ stdin ]:6: Can't open '/c.txt': Permission denied
cat: /c.txt: No such file or directory
osh_.cc35 >| to clobber

[osh_.cc stdout] Expected 'status=1\nXX\nZZ\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py36 &> redirects stdout and stderr

[osh_.py stdout] Expected 'ok\nok\n', got ''
[osh_.py status] Expected 0, got 2

stdout:
stderr: 
  stdout_stderr.py &> $TMP/f.txt
                   ^~
[ stdin ]:1: Can't open '/f.txt': Permission denied
grep: /f.txt: No such file or directory
grep: /f.txt: No such file or directory
osh_.cc36 &> redirects stdout and stderr

[osh_.cc stdout] Expected 'ok\nok\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py37 1>&- to close file descriptor

[osh_.py stdout] Expected u'hello\n', got ''
[osh_.py status] Expected 0, got 2

stdout:
stderr: 
  exec 5> "$TMP/f.txt"
       ^~
[ stdin ]:1: Can't open '/f.txt': Permission denied
  echo hello >&5
             ^~
[ stdin ]:2: 5: Bad file descriptor
Error closing descriptor 5: Bad file descriptor
osh I/O error: Bad file descriptor
osh_.cc37 1>&- to close file descriptor

[osh_.cc stdout] Expected u'hello\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py38 1>&2- to move file descriptor

[osh_.py stdout] Expected u'hello5\nworld6\n', got ''
[osh_.py status] Expected 0, got 2

stdout:
stderr: 
  exec 5> "$TMP/f.txt"
       ^~
[ stdin ]:1: Can't open '/f.txt': Permission denied
  echo hello5 >&5
              ^~
[ stdin ]:2: 5: Bad file descriptor
  exec 6>&5-
       ^~~
[ stdin ]:3: 5: Bad file descriptor
  echo world5 >&5
              ^~
[ stdin ]:4: 5: Bad file descriptor
  echo world6 >&6
              ^~
[ stdin ]:5: 6: Bad file descriptor
Error closing descriptor 6: Bad file descriptor
osh I/O error: Bad file descriptor
osh_.cc38 1>&2- to move file descriptor

[osh_.cc stdout] Expected u'hello5\nworld6\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc39 1>&2- (Bash bug: fail to restore closed fd)

[osh_.cc status] Expected 2, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py40 <> for read/write

[osh_.py stdout] Expected u'line=first\nCONTENTS\nfirst\nsecond\n', got 'line=\nCONTENTS\n'
[osh_.py status] Expected 0, got 1

stdout:
line=
CONTENTS
stderr:
  echo first >$TMP/rw.txt
             ^
[ stdin ]:1: Can't open '/rw.txt': Permission denied
  exec 8<>$TMP/rw.txt
       ^~~
[ stdin ]:2: Can't open '/rw.txt': Permission denied
  read line <&8
            ^~
[ stdin ]:3: 8: Bad file descriptor
  echo second 1>&8
              ^~~
[ stdin ]:5: 8: Bad file descriptor
cat: /rw.txt: No such file or directory
osh_.cc40 <> for read/write

[osh_.cc stdout] Expected u'line=first\nCONTENTS\nfirst\nsecond\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py41 <> for read/write named pipes

[osh_.py stdout] Expected 'line1=first line2=second\n', got ''
[osh_.py status] Expected 0, got 2

stdout:
stderr: 
  mkfifo "$TMP/f.pipe"
  ^~~~~~
[ stdin ]:2: 'mkfifo' not found
  exec 8<> "$TMP/f.pipe"
       ^~~
[ stdin ]:3: Can't open '/f.pipe': Permission denied
  echo first >&8
             ^~
[ stdin ]:4: 8: Bad file descriptor
  echo second >&8
              ^~
[ stdin ]:5: 8: Bad file descriptor
  read line1 <&8
             ^~
[ stdin ]:6: 8: Bad file descriptor
  read line2 <&8
             ^~
[ stdin ]:7: 8: Bad file descriptor
Error closing descriptor 8: Bad file descriptor
osh I/O error: Bad file descriptor
osh_.cc41 <> for read/write named pipes

[osh_.cc stdout] Expected 'line1=first line2=second\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
  mkfifo "$TMP/f.pipe"
  ^~~~~~
[ stdin ]:2: 'mkfifo' not found
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py42 &>> appends stdout and stderr

[osh_.py stdout] Expected 'ok\nok\nok\n', got ''
[osh_.py status] Expected 0, got 2

stdout:
stderr: 
  echo "ok" > $TMP/f.txt
            ^
[ stdin ]:6: Can't open '/f.txt': Permission denied
  stdout_stderr.py &>> $TMP/f.txt
                   ^~~
[ stdin ]:7: Can't open '/f.txt': Permission denied
grep: /f.txt: No such file or directory
grep: /f.txt: No such file or directory
grep: /f.txt: No such file or directory
osh_.cc42 &>> appends stdout and stderr

[osh_.cc stdout] Expected 'ok\nok\nok\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc43 exec redirect then various builtins

[osh_.cc stdout] Expected 'done\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc44 >$file touches a file

[osh_.cc stdout] Expected 'status=1\nstatus=0\n', got 'status=1\n'
[osh_.cc stderr] Expected u'', got "osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.\n"
[osh_.cc status] Expected 0, got -6

stdout:
status=1
stderr:
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc45 $(< $file) yields the contents of the file

[osh_.cc stdout] Expected 'FOO\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc46 $(< file) with more statements

[osh_.cc stdout] Expected 'begin\n---\nend\n---\n\n---\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh_.cc47 < file in pipeline and subshell doesn't work

[osh_.cc stdout] Expected 'end\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc48 2>&1 with no command

[osh_.cc stdout] Expected 'status=42\nstatus=0\n', got 'status=42\n'
[osh_.cc stderr] Expected u'', got "osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.\n"
[osh_.cc status] Expected 0, got -6

stdout:
status=42
stderr:
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc49 2&>1 (is it a redirect or is it like a&>1)

[osh_.cc stdout] Expected 'status=127\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh50 can't mention big file descriptor

stdout:
hi
hi
hi 100
stderr:
osh_.py50 can't mention big file descriptor

stdout:
hi
hi
hi 100
stderr:
osh_.cc50 can't mention big file descriptor

[osh_.cc stdout] Expected 'hi\nhi\nhi 100\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc51 : >/dev/null 2> / (OSH regression: fail to pop fd frame)

[osh_.cc stdout] Expected 'hello\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc52 echo foo >&100 (OSH regression: does not fail with invalid fd 100)

[osh_.cc status] Expected 1, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.cc53 echo foo >&N where N is first unused fd

[osh_.cc status] Expected 1, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:139: void posix::dup2(int, int): Assertion `0' failed.
osh_.py54 exec {fd}>&- (OSH regression: fails to close fd)

[osh_.py stdout] Expected 'foo\n', got ''
[osh_.py status] Expected 0, got 1
[osh_.py stderr] Found 'Traceback (most recent'

stdout:
stderr: 
Traceback (most recent call last):
  File "/home/andy/git/oilshell/oil/bin/osh_eval.py", line 71, in <module>
    sys.exit(main(sys.argv))
  File "/home/andy/git/oilshell/oil/bin/osh_eval.py", line 39, in main
    status = pure.Main('osh', arg_r, environ, login_shell, loader, None)
  File "/home/andy/git/oilshell/oil/core/pure.py", line 497, in Main
    cmd_flags=cmd_eval.IsMainProgram)
  File "/home/andy/git/oilshell/oil/core/main_loop.py", line 168, in Batch
    is_return, is_fatal = cmd_ev.ExecuteAndCatch(node, cmd_flags=cmd_flags)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 1470, in ExecuteAndCatch
    status = self._Execute(node)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 1317, in _Execute
    status, check_errexit = self._Dispatch(node, pipeline_st)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 626, in _Dispatch
    status = self._RunSimpleCommand(cmd_val, node.do_fork)
  File "/home/andy/git/oilshell/oil/osh/cmd_eval.py", line 476, in _RunSimpleCommand
    return self.shell_ex.RunSimpleCommand(cmd_val, do_fork)
  File "/home/andy/git/oilshell/oil/core/executor.py", line 188, in RunSimpleCommand
    status = self.RunBuiltin(builtin_id, cmd_val)
  File "/home/andy/git/oilshell/oil/core/executor.py", line 116, in RunBuiltin
    builtin_func = self.builtins[builtin_id]
KeyError: 3
osh_.cc54 exec {fd}>&- (OSH regression: fails to close fd)

[osh_.cc stdout] Expected 'foo\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: mycpp/mylib.h:671: V Dict<int, vm::_Builtin *>::index(K) [K = int, V = vm::_Builtin *]: Assertion `0' failed.