Commit 48474aa 1 parent 4ed53e1 commit 48474aa Copy full SHA for 48474aa
File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 553
553
# # END
554
554
555
555
# ### : >/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
557
557
# following case, the fd frame remains after the redirection failure
558
558
# "2> /" so that the effect of redirection ">/dev/null" remains after
559
559
# the completion of the command.
@@ -574,6 +574,27 @@ echo foo >&$fd
574
574
# # status: 1
575
575
# # OK dash status: 2
576
576
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
+
577
598
# ### exec {fd}>&- (OSH regression: fails to close fd)
578
599
# mksh, dash do not implement {fd} redirections.
579
600
case $SH in (mksh|dash) exit 1 ;; esac
You can’t perform that action at this time.
0 commit comments