Skip to content

Commit e6dd0dd

Browse files
committed
Minor fix to POSIX mode regression tests in ksh93v-
In ksh93v- [[ -o ?posix ]] doesn't return an error (because it's implemented in the bash mode). However, 'set -o posix' will fail in ksh93v- if it's not in bash compatibility mode, which causes this test script to exit prematurely.
1 parent 5c99eb7 commit e6dd0dd

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/cmd/ksh93/tests/io.sh

+6-9
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,8 @@ fi
642642
643643
# ======
644644
# "&>file" redirection operator, shorthand for ">file 2>&1" (new as of 93u+m; inherited from old SHOPT_BASH)
645-
if [[ -o ?posix ]]
646-
then set -o posix
645+
if [[ -o ?posix ]] && command set -o posix
646+
then
647647
# This should print in a background job, then create an empty file, as '>aha1.txt' is a separate command.
648648
eval ' print -u1 bad1 &>aha1.txt
649649
print -u2 bad2 &>aha2.txt
@@ -657,15 +657,12 @@ then set -o posix
657657
' >/dev/null 2>&1
658658
[[ $(< aha1.txt) == ok1 ]] || err_exit '&> does not redirect stdout'
659659
[[ $(< aha2.txt) == ok2 ]] || err_exit '&> does not redirect stderr'
660-
fi
661-
662-
# In POSIX mode, file descriptors > 2 should remain open when invoking another program
663-
if [[ -o ?posix ]]
664-
then (set -o posix; exec 7>ok.txt; "$SHELL" -c 'print ok >&7' 2>/dev/null)
660+
# In POSIX mode, file descriptors > 2 should remain open when invoking another program
661+
(set -o posix; exec 7>ok.txt; "$SHELL" -c 'print ok >&7' 2>/dev/null)
665662
[[ $(<ok.txt) == ok ]] || err_exit 'File descriptors > 2 not inherited in POSIX mode'
663+
(exec 7>bad.txt; "$SHELL" -c 'print bad >&7' 2>/dev/null)
664+
[[ $(<bad.txt) == '' ]] || err_exit 'File descriptors > 2 inherited without POSIX mode' "(got $actual)"
666665
fi
667-
(exec 7>bad.txt; "$SHELL" -c 'print bad >&7' 2>/dev/null)
668-
[[ $(<bad.txt) == '' ]] || err_exit 'File descriptors > 2 inherited without POSIX mode' "(got $actual)"
669666
670667
# ======
671668
# File descriptor leak with process substitution

0 commit comments

Comments
 (0)