-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Parameter parsing/passing: an unquoted argument that starts with a "-" (hyphen) is broken in two at the first "." (period) #6291
Copy link
Copy link
Open
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIn-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productKeepOpenThe bot will ignore these and not auto-closeThe bot will ignore these and not auto-closeUp-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-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Milestone
Metadata
Metadata
Assignees
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIn-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productKeepOpenThe bot will ignore these and not auto-closeThe bot will ignore these and not auto-closeUp-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-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Related: #6292 and #6360
Note that
.should receive no special treatment in tokens such as-foo=bar.baz, because the token is unquoted and does not start with a special char. ($ @ ( ' ") and should therefore result in interpretation as an (expandable) string, according to about_Parsing.In reality, though, the unexpected special treatment stems from
-being the 1st character, which causes interpretation as a parameter name, even though that doesn't apply in this case.Steps to reproduce
Expected behavior
Actual behavior
The token was unexpectedly broken in two. Note that this equally applies when calling external utilities.
And it is indeed in the context of calling external programs that an argument with such (non-PowerShell) syntax (
-<param-name>=<value>) may need to be passed - see this SO question and this one.(PSv2 exhibited a variation of the bug - see this SO question.)
Environment data
Workarounds