EvalInteractive now uses a closed channel for input.

This prevents commands like `from-json` from hanging elvish when they appear
as the first form of a pipeline.
This commit is contained in:
Qi Xiao 2016-02-10 21:46:02 +01:00
parent 2fb73f4680
commit 018de2ad8b

View File

@ -165,6 +165,9 @@ func (ev *Evaler) Eval(name, text string, n *parse.Chunk, ports []*Port) error {
}
func (ev *Evaler) EvalInteractive(text string, n *parse.Chunk) error {
inCh := make(chan Value)
close(inCh)
outCh := make(chan Value, outChanSize)
outDone := make(chan struct{})
go func() {
@ -175,7 +178,7 @@ func (ev *Evaler) EvalInteractive(text string, n *parse.Chunk) error {
}()
ports := []*Port{
{File: os.Stdin},
{File: os.Stdin, Chan: inCh},
{File: os.Stdout, Chan: outCh},
{File: os.Stderr},
}