Skip to content

Commit ef7f217

Browse files
committed
fix for scala#22443
1 parent 0e567c1 commit ef7f217

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

dist/libexec/common-shared

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@
66
# * Credits: This script is based on the script generated by sbt-pack.
77
# *--------------------------------------------------------------------------*/
88

9-
# save terminal settings
10-
saved_stty=$(stty -g 2>/dev/null)
11-
# clear on error so we don't later try to restore them
12-
if [[ ! $? ]]; then
13-
saved_stty=""
9+
if [ -e /usr/bin/tty -a "`tty`" != "not a tty" -a ! -p /dev/stdin ]; then
10+
isterminal=1
11+
# save terminal settings
12+
saved_stty=$(stty -g 2>/dev/null)
13+
# clear on error so we don't later try to restore them
14+
if [[ ! $? ]]; then
15+
saved_stty=""
16+
fi
17+
else
18+
isterminal=0
1419
fi
1520

1621
# restore stty settings (echo in particular)
1722
function restoreSttySettings() {
18-
stty $saved_stty
23+
[ $isterminal -eq 1 ] && stty $saved_stty
1924
saved_stty=""
2025
}
2126

@@ -61,7 +66,7 @@ if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
6166
CYGPATHCMD=`which cygpath 2>/dev/null`
6267
case "$TERM" in
6368
rxvt* | xterm* | cygwin*)
64-
stty -icanon min 1 -echo
69+
[ $isterminal -eq 1 ] && stty -icanon min 1 -echo
6570
JAVA_OPTS="$JAVA_OPTS -Djline.terminal=unix"
6671
;;
6772
esac

0 commit comments

Comments
 (0)