-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Add a switch to Select-String that makes it return just strings for convenience and performance #7713
Copy link
Copy link
Closed
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionFirst-Time-IssueEasy issues first time contributors can work on to learn about this projectEasy issues first time contributors can work on to learn about this projectHacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Metadata
Metadata
Assignees
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionFirst-Time-IssueEasy issues first time contributors can work on to learn about this projectEasy issues first time contributors can work on to learn about this projectHacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Related: #7712
Sometimes, all you're interested in is the matching input lines as strings rather than full-blown
[Microsoft.PowerShell.Commands.MatchInfo]instances.Not having to extract the
.Lineproperty in subsequent processing can also significantly improve performance.Update: Performance was originally discussed only with respect to how expensive wrapping the matched strings in
MatchInfoinstances is to begin with: nothing to worry about, apparently - see comments for a discussion.A new switch named, say,
-Bareswitch could instructSelect-Stringto output (undecorated) strings only.Note: I'm suggesting the somewhat abstract name
-Bare, because the abstract logic of this proposal - namely to output "bare" objects that are undecorated (have no ETS properties added to them) / are not wrapped in instances of a helper type - applies to other cmdlets as well, such as in #7537, and its conceivable that other cmdlets may benefit from-Baretoo, such asConvertTo-Jsonin order to solve #5797; other cmdlets could benefit from such a switch too, such asCompare-Object.Update: The case for
-Bareas a general pattern has since been made in #7855.Environment data
Written as of: