Repository navigation
Keep here-doc input that an external program leaves unread - #8
Closed
ExpectedArgument wants to merge 1 commit into
Closed
ExpectedArgument wants to merge 1 commit into
ExpectedArgument wants to merge 1 commit into
Conversation
A here-doc or here-string handed to an external program was copied whole into a pipe for that child alone, so a child that never read stdin used it up and the next reader got nothing. Its unread rest now moves into one pipe the first time an external program is given it, and every later reader, builtin or program, shares that pipe, as with bash's pipe-backed here-documents. While only builtins read it, it stays in memory as before. Fixes hex2f#2.
Author
|
Closing this in favour of #14, which covers the same cases: this PR's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2.
A here-doc or here-string given to an external program was copied whole into a new pipe for that child alone (
Handle::to_stdioforHandle::Mem), so a child that never read stdin used it up and the next reader got nothing.Now the unread rest moves into one pipe the first time an external program is given it (
mem_pipeinio.rs), and every later reader, builtin or program, shares that pipe, as with bash's pipe-backed here-documents. While only builtins read it, it stays in memory as before. The writer thread isn't joined: the data waits in the pipe until it is read, and the thread ends once everything is written or the last reader is gone.Readers that read ahead now behave like Git Bash as well:
{ head -n1; cat; } <<EOFprints only the first line in both, and{ /usr/bin/head -n1; read -r c; } <<< $'x\ny'leavescempty in both.Tests
063_heredoc_unread_input.sh, with expected output from Git Bash 5.3.15 viaregen_expected.ps1. It covers the repros from the issue (a script and a function, here-string and here-doc,x=$(/usr/bin/true)and< file), a launcher that runscygpathand thenexec cat, builtins and programs taking turns at reading, and a 100 KB here-string. It fails with v0.1.0 and passes with this branch.cargo testpasses: unit tests, 62/62 compat scripts andmsys_tmp.