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
Pipe waits for the first command to be finished #1947
Comments
|
This is a core PowerShell design feature and is not likely to be changed as would be a major breaking change due to the way that the pipeline works and is designed. an example to understand how the pipeline is used in Powershell would be like Get-ChildItem C:\scripts\ -Recurse | Where-Object {$_.Name -like "*.ps*1"} | Group-object -Property Extension | Select-Object Count,NameTo break this down we are getting all the items in the C:\Scripts\ folder and recursive folders and then with the collection of objects that would output we pass this to Where-Object using the Pipeline to then only return files that have a ps*1 extension and then with the collection of objects that would output this is then passed again using the pipeline to Group-Object where we get an output based on the grouping of the items based on the file extension and the we pipe this to Select-Object and tell it that we want only the Count and Name returned from that collection The Output we would get from would get something similar to the below Happy to answer any other questions on the PowerShell Pipeline if you have them? |
|
Hi! @kilasuit, I could be off base, but IIRC commands with a proper 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! |
|
@RamblingCookieMonster is correct. Powershell will stream objects down the pipe when it can. A good common example would be to tail a log file and pipe to a search string. Get-Content -Path $path -Tail | Select-String 'Error' But there are other commands that will block the pipe and wait for all the objects before continuing. Sort-Object is an obvious example. |
|
I can't see how this breaks compatibility |
|
Closing as this is a duplicate, see #559. It is fixable, but a bit tricky. |


Since 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:
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 testin Bash), and send any output from first command immediately to the second command.Tested with PowerShell 6.0.0 on Debian GNU/Linux
The text was updated successfully, but these errors were encountered: