| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Jason Shirk (@lzybkr) Can you please take a look when you have time? Thanks! |
Sorry, something went wrong.
| // Expressions for this purpose are kept in 'extraFileRedirectExprs' and will be used later. | ||
| extraFileRedirectExprs.Add(Expression.Call(redirectionExpr, CachedReflectionInfo.FileRedirection_CallDoCompleteForExpression)); | ||
|
|
||
| // The 'UnBind' and 'Dispose' operations on 'FileRedirection' objects must be done in the reversed order of 'Bind' operations. |
There was a problem hiding this comment.
done in the reverse order
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed. Thanks!
Sorry, something went wrong.
There was a problem hiding this comment.
This code has always bothered me - it's more complicated than a redirected command.
I wonder how possible it would be to move most of this logic into a helper method and avoid generating so much complicated code.
Sorry, something went wrong.
|
Jason Shirk (@lzybkr) I opened the issue #4879 to tracking the effort to revisit the implementation of this method. |
Sorry, something went wrong.
When handling file redirection for CommandExpression, we don't call 'DoComplete' on the underlying PipelineProcessor of the FileRedirection object, and thus the EndProcessing method is not called on Out-File, which causes different behaviors between <expr> > out.txt and <expr> | Out-File out.txt. The fix is to make sure 'DoComplete' is called after the stream output has been written to the redirection pipe. Also fix another issue This PR also fixes an issue that could mess up restoring the original pipes. Here is the repro: PS> 1 *> b.txt > a.txt; 123 Cannot perform operation because object "PipelineProcessor" has already been disposed The root cause is that we don't always restore pipes in the correct order. Please see the code changes in Compiler.cs for more details. Fix PowerShell#4812
| Back | FazBrowse Home | New Git URL |
Fix #4812
Summary
When handling file redirection for CommandExpression, we don't call 'DoComplete' on the underlying PipelineProcessor of the FileRedirection object, and thus the EndProcessing method is not called on Out-File, which causes different behaviors between <expr> > out.txt and <expr> | Out-File out.txt.
The fix is to make sure 'DoComplete' is called after the stream output has been written to the redirection pipe.
Also fix another issue
This PR also fixes an issue that could mess up restoring the original pipes. Here is the repro:
The root cause is that we don't always restore pipes in the correct order. Please see the code changes in Compiler.cs for more details.
/cc Michael Klement (@mklement0)