Skip to content

PowerShell can't handle empty commandline parameter #10975

@Aloxaf

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

Metadata

Metadata

Assignees

Labels

Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.WG-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