Open notramo opened 6 years ago
That's the way it should work; considering this a bug.
FWIW, This is really about how elvish determines whether it is interactive. This unexpected behavior is still present:
$ echo "echo 'string'" | elvish
compilation error: variable $edit:completion:matcher not found
/Users/krader/.elvish/rc.elv, line 118: edit:completion:matcher[''] = [p]{ edit:match-prefix &smart-
case $p }
/Users/krader> string
/Users/krader> ⏎
FYI, I have a fix for this. However, all of the tests in pkg/shell/interact_test.go depend on the existing, unwanted, behavior. Those tests need to be changed to use a PTY. Sadly, Go doesn't have any native support for PTYs. Presumably because they are not portable and a niche feature for a language like Go. So the question is whether we want to depend on a Go package like https://github.com/creack/pty or instead rewrite interactive tests to use the expect
utility.
I see that one unit test, pkg/cli/term/setup_unix_test.go, already depends github.com/kr/pty
which is the predecessor of github.com/creack/pty
. Since the former package is no longer being maintained switch that use to the latter package. Also, use the latter package in the tests of interactive behavior. That will, unfortunately, mean the interactive tests won't run on Windows.
I think it shouldn't launch the editor in this case.
If stdin is not a tty,
bash
,sh
, andzsh
reads the script from it: