You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is common to all versions of scala3 that I've tried.
It can be demonstrated with scala3-3.6.3-x86_64-pc-win32.
No such error occurs in scala 2.13.
Minimized code
#!/usr/bin/env -S scalavallines=for {
line <- scala.collection.Iterator.Iterator.continually(scala.io.StdIn.readLine()).takeWhile( _ !=null )
if line !=null
} yield line
printf("%d lines\n", lines.size)
A fix is to not call stty unless there's a tty, as in this modification of scala3-3.6.3-x86_64-pc-win32/libexec/common-shared
#!/usr/bin/env bash#/*--------------------------------------------------------------------------# * Credits: This script is based on the script generated by sbt-pack.# *--------------------------------------------------------------------------*/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 themif [[ !$? ]];then
saved_stty=""fielse
isterminal=0
fi# restore stty settings (echo in particular)functionrestoreSttySettings() {
[ $isterminal-eq 1 ] && stty $saved_stty
saved_stty=""
}
It's also necessary to condition another call to stty later in the file:
[ $isterminal-eq 1 ] && stty -icanon min 1 -echo
Making stty calls conditional fixes the problem in all my manually tested environments, including cygwin, msys64, git-bash, WSL ubuntu, Linux Ubuntu and OSX.
I can submit a PR.
The text was updated successfully, but these errors were encountered:
I can't reproduce this with my MacBook, I'm undusting my old Windows machine to try to reproduce the issue; since you're using scala3-3.6.3-x86_64-pc-win32
I believe the fix does the right thing on a MacBook, and I assume it doesn't matter whether the problem it fixes is reproducible there.
This is a subtle test due to a variety of behaviors across different supported systems. My goal was to find an expression that does the same thing on all tested systems in both the tty context, and when running on the receiving end of a pipe.
I tested it against Linux, MaxBook, and several varieties of Window shell and console environments. Please let me know if it fails anywhere in either context.
Compiler version
This is common to all versions of scala3 that I've tried.
It can be demonstrated with
scala3-3.6.3-x86_64-pc-win32
.No such error occurs in
scala 2.13
.Minimized code
Output
Expectation
No error message
A fix is to not call
stty
unless there's atty
, as in this modification ofscala3-3.6.3-x86_64-pc-win32/libexec/common-shared
It's also necessary to condition another call to
stty
later in the file:Making
stty
calls conditional fixes the problem in all my manually tested environments, includingcygwin
,msys64
,git-bash
,WSL ubuntu
,Linux Ubuntu
andOSX
.I can submit a PR.
The text was updated successfully, but these errors were encountered: