Skip to content

PowerShell can't handle empty commandline parameter #10975

Closed

Description

@Aloxaf

Steps to reproduce

pwsh-preview ''
pwsh-preview -c ''
pwsh-preview -c ' '
# or in pwsh: pwsh-preview ' '

Expected behavior

'' or ' ' should be parsed correctly.

Actual behavior

Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'value')
   at System.String.IndexOf(String value, Int32 startIndex, Int32 count, StringComparison comparisonType)
   at System.String.IndexOf(String value, StringComparison comparisonType)
   at Microsoft.PowerShell.CommandLineParameterParser.MatchSwitch(String switchKey, String match, String smallestUnambiguousMatch)
   at Microsoft.PowerShell.CommandLineParameterParser.EarlyParse(String[] args)
   at Microsoft.PowerShell.UnmanagedPSEntry.Start(String consoleFilePath, String[] args, Int32 argc)
   at Microsoft.PowerShell.ManagedPSEntry.Main(String[] args)

If run it in bash/zsh, I will also get a core dump.

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0-preview.5
PSEdition                      Core
GitCommitId                    7.0.0-preview.5
OS                             Linux 5.3.7-zen1-2-zen #1 ZEN SMP PREEMPT @1572002936
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    Issue-Question
    on Nov 2, 2019
  2. added
    WG-Engine
    on Nov 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-QuestionResolution-FixedWG-Engine

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions