From ef7f217abe44b922fec01bbad23109fe6082cdc6 Mon Sep 17 00:00:00 2001 From: philwalk Date: Thu, 23 Jan 2025 16:17:16 -0700 Subject: [PATCH 1/2] fix for #22443 --- dist/libexec/common-shared | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/dist/libexec/common-shared b/dist/libexec/common-shared index fa1e62c09241..bcf5d52d95b7 100644 --- a/dist/libexec/common-shared +++ b/dist/libexec/common-shared @@ -6,16 +6,21 @@ # * Credits: This script is based on the script generated by sbt-pack. # *--------------------------------------------------------------------------*/ -# save terminal settings -saved_stty=$(stty -g 2>/dev/null) -# clear on error so we don't later try to restore them -if [[ ! $? ]]; then - saved_stty="" +if [ -e /usr/bin/tty -a "`tty`" != "not a tty" -a ! -p /dev/stdin ]; then + isterminal=1 + # save terminal settings + saved_stty=$(stty -g 2>/dev/null) + # clear on error so we don't later try to restore them + if [[ ! $? ]]; then + saved_stty="" + fi +else + isterminal=0 fi # restore stty settings (echo in particular) function restoreSttySettings() { - stty $saved_stty + [ $isterminal -eq 1 ] && stty $saved_stty saved_stty="" } @@ -61,7 +66,7 @@ if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then CYGPATHCMD=`which cygpath 2>/dev/null` case "$TERM" in rxvt* | xterm* | cygwin*) - stty -icanon min 1 -echo + [ $isterminal -eq 1 ] && stty -icanon min 1 -echo JAVA_OPTS="$JAVA_OPTS -Djline.terminal=unix" ;; esac From 8d2bbc5a68bd7051d23095bbd09f87aad5d5de20 Mon Sep 17 00:00:00 2001 From: philwalk Date: Mon, 10 Mar 2025 10:21:40 -0600 Subject: [PATCH 2/2] resolve feedback: clear isterminal on error --- dist/libexec/common-shared | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/libexec/common-shared b/dist/libexec/common-shared index bcf5d52d95b7..48476c11b63e 100644 --- a/dist/libexec/common-shared +++ b/dist/libexec/common-shared @@ -13,6 +13,7 @@ if [ -e /usr/bin/tty -a "`tty`" != "not a tty" -a ! -p /dev/stdin ]; then # clear on error so we don't later try to restore them if [[ ! $? ]]; then saved_stty="" + isterminal=0 fi else isterminal=0