Skip to content
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

Closed
xiaq opened this issue Feb 18, 2018 · 4 comments
Closed
Labels

Comments

@xiaq
Copy link
Member

@xiaq 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 bug label Feb 18, 2018
@scurest
Copy link

@scurest 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
Copy link
Member Author

@xiaq xiaq commented Mar 2, 2018

Aha. That is very correct.

@xiaq xiaq closed this in 7b74961 Mar 2, 2018
@scurest
Copy link

@scurest 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 Redirecting input of "each" to a file makes it not return 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 removed this from the 0.14 milestone Apr 6, 2019
krader1961 added a commit to krader1961/elvish that referenced this issue Sep 12, 2020
krader1961 added a commit to krader1961/elvish that referenced this issue Sep 13, 2020
krader1961 added a commit to krader1961/elvish that referenced this issue Oct 11, 2020
@xiaq xiaq closed this in #1150 Nov 7, 2020
xiaq added a commit that referenced this issue Nov 7, 2020
@ShalokShalom
Copy link

@ShalokShalom ShalokShalom commented Mar 28, 2021

This can be corrected in the documentation: https://elv.sh/learn/effective-elvish.html#mixing-bytes-and-values

Screenshot_20210328_235324

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants