-
Notifications
You must be signed in to change notification settings - Fork 365
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
PSUseProcessBlockForPipelineCommand does not recognize use of $input within an End block #1912
Comments
This is by design, if you take a parameter that takes input from a pipeline then there is an expectation that the process block is going to handle it since it has to run multiple times. Begin and end blocks only run once in a pipeline. Its not complaining about |
@StevenBucher98 The In the example above, |
I think since you still have a parameter |
@StevenBucher98 There's more than one way to consume that pipeline data. Explicit usage in the |
@brianary using $input in the end is not something that we recommend and will likely lead to misunderstandings as the following example shows. function f1 {
param ([parameter(ValueFromPipeline=$true)]$a)
BEGIN { "input value: '$input' `tinput count: $($input.count) `tvalue of a: '$a'" }
PROCESS { "input value: '$input' `tinput count: $($input.count) `tvalue of a: '$a'" }
END { "input value: '$input' `tinput count: $($input.count) `tvalue of a: '$a'" }
} when run, the output is as follows: PS> 1..3 | f1
input value: '' input count: 0 value of a: ''
input value: '1' input count: 1 value of a: '1'
input value: '2' input count: 1 value of a: '2'
input value: '3' input count: 1 value of a: '3'
input value: '' input count: 0 value of a: '3' As you can see, $input has no value in both the This rule is expressing the appropriate expectation that if you have pipelined parameters, you need to handle them in a |
@JamesWTruher function f1 {
param ([parameter(ValueFromPipeline=$true)]$a)
END { "input value: '$input' `tinput count: $($input.count) `tvalue of a: '$a'" }
} input value: '1 2 3' input count: 3 value of a: '3' |
Steps to reproduce
Expected behavior
(no output)
Actual behavior
Environment data
The text was updated successfully, but these errors were encountered: