Skip to content

Command line parameters prefixed /- #12013

Closed

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

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Mar 4, 2020
  2. changed the title [-]My bug report[/-] [+]Command line parameters prefixed /-[/+] on Mar 4, 2020
  3. iSazonov commented on Mar 5, 2020

    @iSazonov
    Collaborator

    Before we can fix this we should merge #11482 and then add xUnit tests.

  4. added
    Issue-BugIssue has been identified as a bug in the product
    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
    First-Time-IssueEasy issues first time contributors can work on to learn about this project
    and removed
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Jan 16, 2021
  5. davidBar-On commented on Apr 1, 2021

    @davidBar-On
    Contributor

    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.

  6. iSazonov commented on Apr 1, 2021

    @iSazonov
    Collaborator

    We will need new test in test_CommandLineParser.cs file.
    I guess it could be like "Assert.Throws<System.ArgumentException>(() => cpp.Parse(commandLine));"

  7. added a commit that references this issue on Apr 2, 2021
  8. davidBar-On commented on Apr 2, 2021

    @davidBar-On
    Contributor

    Submitted PR #15142 with a proposed fix.

  9. added a commit that references this issue on Apr 13, 2021
  10. rjmholt commented on Apr 14, 2021

    @rjmholt
    Collaborator

    Fixed in #15142

  11. added a commit that references this issue on Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    First-Time-IssueEasy issues first time contributors can work on to learn about this projectIssue-BugIssue has been identified as a bug in the productUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions