Skip to content

Commit

Permalink
[test/spec] Add tests for redirections
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Mar 21, 2020
1 parent 7ea281a commit 8dd5a02
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions spec/redirect.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,39 @@ cat $TMP/named-fd.txt
## N-I dash/mksh stdout-json: ""
## N-I dash/mksh status: 127

#### Double digit fd (20> file)
exec 20> "$TMP/double-digit-fd.txt"
echo hello20 >&20
cat "$TMP/double-digit-fd.txt"
## stdout: hello20
## BUG dash stdout-json: ""
## BUG dash status: 127

#### : 9> fdleak (OSH regression)
: 9> "$TMP/fd.txt"
( echo world >&9 )
cat "$TMP/fd.txt"
## stdout-json: ""

#### : 3>&3 (OSH regression)
: 3>&3
echo hello
## stdout: hello
## BUG mksh stdout-json: ""
## BUG mksh status: 1

#### : 3>&- << EOF (OSH regression: fail to restore fds)
exec 3> "$TMP/fd.txt"
echo hello 3>&- << EOF
EOF
echo world >&3
exec 3>&-
cat "$TMP/fd.txt"
## STDOUT:
hello
world
## END

#### Redirect function stdout
f() { echo one; echo two; }
f > $TMP/redirect-func.txt
Expand Down Expand Up @@ -299,6 +332,24 @@ cat "$TMP/f.txt"
## N-I mksh status: 1
## N-I mksh stdout-json: ""

#### 1>&2- (Bash bug: fail to restore closed fd)
exec 5> "$TMP/f.txt"
: 6>&5 5>&-
echo hello >&5
: 6>&5-
echo world >&5
exec 5>&-
cat "$TMP/f.txt"
## STDOUT:
hello
world
## END
## BUG bash stdout: hello
## N-I dash status: 2
## N-I dash stdout-json: ""
## N-I mksh status: 1
## N-I mksh stdout-json: ""

#### <> for read/write
echo first >$TMP/rw.txt
exec 8<>$TMP/rw.txt
Expand Down

0 comments on commit 8dd5a02

Please sign in to comment.