-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-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 reclassifWG-Languageparser, language semanticsparser, language semantics
Description
In order to pass a parameter value that looks like a parameter name you currently have to use quoting - sometimes.
However, if you explicitly precede the value with its parameter name as opposed to passing it positionally, no quoting should be necessary.
Especially with respect to PowerShell's CLI and all its quoting headaches, this extra quoting requirement should be reconsidered - see #4351
Steps to reproduce
'hi'>'-t.txt'; Get-Content '-t.txt'; Get-Content -LiteralPath -t.txtExpected behavior
hi
hi
The two Get-Content commands should be equivalent:
- In the 1st case, the quoting implies that
-t.txtis a parameter value rather than a name. - In the 2nd case, the explicit use of parameter
-LiteralPath, which requires a value, should unambiguously identify the next token as the parameter value - even if it starts with-- whether quoted or not.
Actual behavior
hi
Get-Content : Parameter cannot be processed because the parameter name 't' is ambiguous. Possible matches include: -TotalCount -Tail.
...
That is, despite being preceded by -LiteralPath, which requires a parameter value,
unquoted -t.txt was not interpreted as that parameter's value, but as another parameter name.
Environment data
PowerShell Core v6.0.0-beta.5 on macOS 10.12.6
PowerShell Core v6.0.0-beta.5 on Ubuntu 16.04.3 LTS
PowerShell Core v6.0.0-beta.5 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Windows PowerShell v5.1.15063.483 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)Metadata
Metadata
Assignees
Labels
Issue-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 reclassifWG-Languageparser, language semanticsparser, language semantics