Call 'DoComplete' when handling FileRedirection for CommandExpression#4847
Merged
lzybkr merged 5 commits intoPowerShell:masterfrom Sep 20, 2017
Merged
Call 'DoComplete' when handling FileRedirection for CommandExpression#4847lzybkr merged 5 commits intoPowerShell:masterfrom
lzybkr merged 5 commits intoPowerShell:masterfrom
Conversation
Member
Author
|
@lzybkr Can you please take a look when you have time? Thanks! |
lzybkr
reviewed
Sep 20, 2017
| // 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. |
lzybkr
approved these changes
Sep 20, 2017
Contributor
lzybkr
left a comment
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
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 @mklement0