From 8ad56f90abc37c17c662cc98aeb5a531e18b4925 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Mon, 13 Jul 2020 21:24:14 +0200 Subject: [PATCH] Add FreeBSD stty workaround for pty regression tests Apparently, on FreeBSD, the stty command does not work correctly for setting 'erase' or 'kill' on a pty pseudoterminal. I've no idea whether the bug is in FreeBSD stty or in AST pty, but in any case, a workaround is needed for the time being. src/cmd/ksh93/tests/pty.sh: - Save terminal state on init; set a trap to restore it on exit. - Issue 'stty erase ^H kill ^X' on the real terminal before entering pty pseudoterminals. Resolves #44. --- src/cmd/ksh93/tests/pty.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmd/ksh93/tests/pty.sh b/src/cmd/ksh93/tests/pty.sh index 5c0c50b1a..db2976817 100755 --- a/src/cmd/ksh93/tests/pty.sh +++ b/src/cmd/ksh93/tests/pty.sh @@ -44,6 +44,12 @@ integer Errors=0 lineno=1 [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } whence -q pty || { lineno=$LINENO; err\_exit "$LINENO" "pty command not found -- tests skipped"; exit 0; } +# On FreeBSD, the stty command does not appear to work correctly on a pty pseudoterminal. +# To avoid a couple of false regressions, we have to set 'erase' and 'kill' on the real terminal. +stty_restore=$(stty -g) || { lineno=$LINENO; err\_exit "$LINENO" "could not save terminal state -- tests skipped"; exit 0; } +trap 'stty "$stty_restore"' EXIT # note: on ksh, the EXIT trap is also triggered for termination due to a signal +stty erase ^H kill ^X + bintrue=$(whence -p true) x=$( $SHELL <<- \EOF