-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix for #22443: prevent stty from being called when not running in a terminal #22444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,22 @@ | |
# * 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="" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you clear the cached % stty
speed 9600 baud;
lflags: echoe echoke echoctl pendin
iflags: iutf8
oflags: -oxtabs
cflags: cs8 -parenb
% stty ""
stty: illegal option --
usage: stty [-a | -e | -g] [-f file] [arguments] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point. Clearing |
||
isterminal=0 | ||
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 +67,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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and played a bit with the locale and it seems that
tty
will always output 'not a tty' regardless of the current locale. Which means that we can rely on that output being in the same language.