Repository navigation
Call 'DoComplete' when handling FileRedirection for CommandExpression - #4847
Merged
Merged
Conversation
Dongbo Wang (daxian-dbw)
requested review from
Bruce Payette (BrucePay) and
sergei (vors)
as code owners
September 15, 2017 23:45
Member
Author
|
Jason Shirk (@lzybkr) Can you please take a look when you have time? Thanks! |
| // 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. |
Contributor
There was a problem hiding this comment.
done in the reverse order
Member
Author
There was a problem hiding this comment.
Fixed. Thanks!
Jason Shirk (lzybkr)
approved these changes
Sep 20, 2017
Jason Shirk (lzybkr)
left a comment
Contributor
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.
Member
Author
|
Jason Shirk (@lzybkr) I opened the issue #4879 to tracking the effort to revisit the implementation of this method. |
sergei (vors)
removed their request for review
September 25, 2017 00:34
Thatgfsj (Thatgfsj)
pushed a commit
to Thatgfsj-contribs/PowerShell
that referenced
this pull request
Aug 6, 2026
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
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.
Fix #4812
Summary
When handling file redirection for CommandExpression, we don't call 'DoComplete' on the underlying
PipelineProcessorof theFileRedirectionobject, and thus theEndProcessingmethod is not called onOut-File, which causes different behaviors between<expr> > out.txtand<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.csfor more details./cc Michael Klement (@mklement0)