FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix piping more than one CommandInfo to Get-Command by SteveL-MSFT · Pull Request #10929 · PowerShell/PowerShell · GitHub

Fix piping more than one CommandInfo to Get-Command - #10929

Merged
Aditya Patwardhan (adityapatwardhan) merged 2 commits into
PowerShell:masterfrom
SteveL-MSFT:getcommand-pipeline
Nov 7, 2019
Merged

Fix piping more than one CommandInfo to Get-Command#10929
Aditya Patwardhan (adityapatwardhan) merged 2 commits into
PowerShell:masterfrom
SteveL-MSFT:getcommand-pipeline

Conversation

Steve Lee (SteveL-MSFT) commented Oct 29, 2019
edited
Loading

Copy link
Copy Markdown
Member

PR Summary

Piping multiple CommandInfo to Get-Command only returns the first result. This is because during discovery of the command it internally builds a cache of commands it has already seen. On the second (or more) times ProcessRecord() is called, that cache is already filled with some results. If the requested CommandInfo (which binds to -Verb and -Noun) happens to be in that cache, then the cmdlet considers that a duplicate and doesn't return that result. The fix in this case is to clear the cache at the start of ProcessRecord() to treat each search as independent.

PR Context

Fix #10851

PR Checklist

Copy link
Copy Markdown
Member Author

PoshChan-Bot (@PoshChan) please retry linux

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), successfully started retry of PowerShell-CI-Linux

Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Oct 30, 2019
Ilya (iSazonov) added this to the 7.0.0-preview.6 milestone Oct 30, 2019
Aditya Patwardhan (adityapatwardhan) merged commit ef64321 into PowerShell:master Nov 7, 2019

Copy link
Copy Markdown
Contributor

Unfortunately, this PR didn't fix all problems, because the following tests fail:

function foo {}; set-alias foo foo

(gcm -all foo | gcm).Count | Should -Be 2

(gcm -all foo | gcm).ComandType | Should -Be Alias, Function

Copy link
Copy Markdown
Member Author

Michael Klement (@mklement0) those are different issues not related to piping to Get-Command, please open a new issue for them

Steve Lee (SteveL-MSFT) deleted the getcommand-pipeline branch November 7, 2019 22:49

Copy link
Copy Markdown
Contributor

Steve Lee (@SteveL-MSFT): These tests do pipe to Get-Command (whose built-in alias is gcm). In what way is this a different issue?

Copy link
Copy Markdown
Contributor

If it helps with getting this resolved, please see #11017

Steve Lee (SteveL-MSFT) commented Nov 7, 2019
edited
Loading

Copy link
Copy Markdown
Member Author

Michael Klement (@mklement0) my mistake, I only saw the left side of the pipe. In anycase, the root cause is something different.

Copy link
Copy Markdown

🎉v7.0.0-preview.6 has been released which incorporates this pull request.:tada:

Handy links:

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

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get-Command doesn't recognize System.Management.Automation.CommandInfo (its own output type) as pipeline input

6 participants


Back | FazBrowse Home | New Git URL