Skip to content

Commit 48474aa

Browse files
committed
[test/spec] Add a test case for invalid redirections
1 parent 4ed53e1 commit 48474aa

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

spec/redirect.test.sh

+22-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ hi
553553
## END
554554

555555
#### : >/dev/null 2> / (OSH regression: fail to pop fd frame)
556-
# oil 0.8.pre4 fails to restore fds after redirection failure In the
556+
# oil 0.8.pre4 fails to restore fds after redirection failure. In the
557557
# following case, the fd frame remains after the redirection failure
558558
# "2> /" so that the effect of redirection ">/dev/null" remains after
559559
# the completion of the command.
@@ -574,6 +574,27 @@ echo foo >&$fd
574574
## status: 1
575575
## OK dash status: 2
576576

577+
#### echo foo >&N where N is first unused fd
578+
# 1. prepare default fd for internal uses
579+
minfd=10
580+
case ${SH##*/} in
581+
(mksh) minfd=24 ;;
582+
(osh) minfd=100 ;;
583+
esac
584+
585+
# 2. prepare first unused fd
586+
fd=$minfd
587+
is-fd-open() { : >&$1; }
588+
while is-fd-open "$fd"; do
589+
: $((fd+=1))
590+
done
591+
592+
# 3. test
593+
echo foo >&$fd
594+
## stdout-json: ""
595+
## status: 1
596+
## OK dash status: 2
597+
577598
#### exec {fd}>&- (OSH regression: fails to close fd)
578599
# mksh, dash do not implement {fd} redirections.
579600
case $SH in (mksh|dash) exit 1 ;; esac

0 commit comments

Comments
 (0)