Repository navigation
Description
This may or may not be intentional.
I was just looking at the code here for completely unrelated reasons:
https://github.com/PowerShell/PowerShell/blob/master/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs#L569
I noticed that (in contrast to Powershell 5.1), a combination of / and - for command line parameters is now allowed.
According to all documentation (in-code and external), one is supposed to pick between -, -- and /, no combination is ever mentioned.
However, the flow of the code also allows for /-.
Is this meant to be possible?
Steps to reproduce
pwsh.exe /-enc JwBUAGgAaQBzACAAaQBzACAAYQAgAHQAZQBzAHQALgAnAA==Expected behavior
Invalid combination of / and -
Actual behavior
Execution of command
> pwsh.exe /-enc JwBUAGgAaQBzACAAaQBzACAAYQAgAHQAZQBzAHQALgAnAA==
This is a test
Environment data
Name Value
---- -----
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.14393
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS: I had a hard time searching for this, since symbols are not really searchable in GitHub. Apologies if this issue already exists.
Activity
[-]My bug report[/-][+]Command line parameters prefixed /-[/+]iSazonov commentedon Mar 5, 2020
Before we can fix this we should merge #11482 and then add xUnit tests.
davidBar-On commentedon Apr 1, 2021
I have a proposed fix for the issue, but I am not sure if additional test should be added. If such tests are required, it is not clear to me were to add them.
iSazonov commentedon Apr 1, 2021
We will need new test in test_CommandLineParser.cs file.
I guess it could be like "Assert.Throws<System.ArgumentException>(() => cpp.Parse(commandLine));"
Fix issue PowerShell#12013 - not allow mixed dash and slash in comman…
davidBar-On commentedon Apr 2, 2021
Submitted PR #15142 with a proposed fix.
Fix issue #12013 - not allow mixed dash and slash in command line par…
rjmholt commentedon Apr 14, 2021
Fixed in #15142
Fix issue PowerShell#12013 - not allow mixed dash and slash in comman…