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

Redirecting input of value-consuming functions to a file makes it not return #600

Open
xiaq opened this Issue Feb 18, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@xiaq
Member

xiaq commented Feb 18, 2018

~> cat in.txt
abc
123
lorem
456
~> each [line]{ echo $line } < in.txt
abc
123
lorem
456
("each" does not return)

@xiaq xiaq added the type:bug label Feb 18, 2018

@scurest

This comment has been minimized.

scurest commented Mar 2, 2018

Same thing for count.

It appears to get blocked forever waiting for the channel band of its input port, which is a BlackholeChan.

elvish/eval/compile_op.go

Lines 525 to 528 in 7969c66

fm.ports[dst] = &Port{
File: f, Chan: BlackholeChan,
CloseFile: true,
}

Maybe the channel should depend on what kind of redir it is (ClosedChan for read redirs?).

@xiaq

This comment has been minimized.

Member

xiaq commented Mar 2, 2018

Aha. That is very correct.

@xiaq xiaq closed this in 7b74961 Mar 2, 2018

@scurest

This comment has been minimized.

scurest commented Mar 2, 2018

This will crash on

put A > a.txt

now because elvish writes to a closed channel ;) I think the channel needs to be picked based on what kind of redir it is: ClosedChan for reads, BlackholeChan for writes and appends(?), ??? for read-writes.

@xiaq xiaq reopened this Mar 2, 2018

@xiaq xiaq changed the title from Redirecting input of "each" to a file makes it not return to Redirecting input of value-consuming functions to a file makes it not return Mar 14, 2018

@xiaq xiaq added this to the 0.13 milestone Mar 16, 2018

@xiaq xiaq added the comp:lang label Mar 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment