Pipe waits for the first command to be finished
See original GitHub issueSince there are 281 open issues, I’m not sure if this is reported before or not
Try a command that takes too long (possibly forever) and produces lots of output, and we want to give the output to another command using pipe, for example:
find / -iname '*.exe' | less
PowerShell waits for the first command to be finished, and then runs the second command and give it the whole output. That is not what Unix pipes have been about for decades! We expect the second command to be executed right after we press enter (try sleep 10 | echo test
in Bash), and send any output from first command immediately to the second command.
Tested with PowerShell 6.0.0 on Debian GNU/Linux
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Why doesn't the 2nd command wait for the output of the 1st ...
In a pipeline producer | consumer , the two sides run concurrently¹. The consumer does not wait for the producer to finish. It...
Read more >How to pipe without waiting for first command to finish?
In Windows PowerShell, when piping to an external program, the input command's output is unexpectedly: collected in full in memory first.
Read more >Bash wait Command with Examples
Introduction. The bash wait command is a Shell command that waits for background running processes to complete and returns the exit status.
Read more >Do pipes know when they have to "wait" for all the data?
Hi, I was wondering if pipes ("|"), or rather the command that follow them, know when they're supposed to wait for all the...
Read more >Bash wait Command with Examples
The wait command is a built-in Bash shell command that waits for termination of a background process. This means that Bash shell will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi!
@kilasuit, I could be off base, but IIRC commands with a proper
process
block implementation will stream their output, allowing something akin to @ilius’ example.I’m guessing there might be some odd behavior if you mix and match output from *nix tools and PowerShell tools, and this would be expected in cases where you have a blocking command (e.g. you need all items to sort them).
Cheers!
I can’t see how this breaks compatibility If a command (like ``Sort-Object
or
Select-Object`) needs the whole input to process, it can wait for the whole input itself, that’s up to the second command (receiver), that does not prevent the first command (sender) or the Shell to send it’s output.https://en.wikipedia.org/wiki/Pipeline_(Unix)