Skip to content

Commit

Permalink
Fix failing pty test and add (fixed) unused test (re: 2a29856, 430e478)
Browse files Browse the repository at this point in the history
src/cmd/ksh93/tests/pty.sh:
- Fix test for ksh93#722 by checking for 'Exit status 0' with 'u'.
  As far as I can tell this fixes the CI failure while still catching
  the crash on bugged commits.
- Add a fixed version of the previously unused regression test from
  ksh93#356. Avoiding the CPU hungry lockup only requires spawning a child
  interactive shell for the crash to occur inside of. (This doesn't
  fix the underlying bug in pty, but merely works around it.)
  • Loading branch information
JohnoKing committed Feb 23, 2024
1 parent 9a6050c commit a6216c0
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/cmd/ksh93/tests/pty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,27 @@ c \Ek
r ^:prompt: "\$SHELL" -o vi -c 'read -s "foo\?:prompt: "'$
!

tst $LINENO << "!"
L crash when discipline functions exit with an error
# https://github.com/ksh93/ksh/issues/346
w "$SHELL"
w PS1.get() {; printf '$ '; trap --invalid-flag 2>/dev/null; }
w PS2.get() {; printf '> '; trap --invalid-flag 2>/dev/null; }
w .sh.tilde.set() {
w case ${.sh.value} in
w '~ret') .sh.value='Exit status is' ;;
w esac
w trap --invalid-flag 2>/dev/null
w }
w echo ~
w echo ~ret
s 50
w echo ~
w echo ~ret $?
u ^Exit status is 0\r\n$
!

((multiline && (SHOPT_VSH || SHOPT_ESH))) && TERM=vt100 tst $LINENO <<"!"
L crash when TERM is undefined
# https://github.com/ksh93/ksh/issues/722
Expand All @@ -1333,8 +1354,7 @@ p :test-2:
w "$SHELL"
p :test-3:
w print Exit status $?
r print
r ^Exit status 0\r\n$
u ^Exit status 0\r\n$
!

# ======
Expand Down

0 comments on commit a6216c0

Please sign in to comment.