Skip to content

Allow passing just a dash as an arg to a file via pwsh - #9479

Merged
Travis Plunk (TravisEz13) merged 1 commit into
PowerShell:masterfrom
SteveL-MSFT:dash-arg
Apr 27, 2019
Merged

Allow passing just a dash as an arg to a file via pwsh#9479
Travis Plunk (TravisEz13) merged 1 commit into
PowerShell:masterfrom
SteveL-MSFT:dash-arg

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Apr 26, 2019

Copy link
Copy Markdown
Member

PR Summary

When processing a file (implicitly or via -File), it looks at the remainings args and constructs parameters to pass to the pipeline. When the first character is a -, it assumes it's a parameter and uses the remainder to be the name of the parameter. If it's a single dash, it ends up being an empty string for the name. This causes the parameter binder to throw which then causes the console host to crash.

Fix is to detect that it's a single dash and pass that as an unnamed parameter which gets handled correctly.

PR Context

Fix #9362

PR Checklist

@SteveL-MSFT

Copy link
Copy Markdown
Member Author

PoshChan-Bot (@PoshChan) please retry linux, macos

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), successfully started retry of PowerShell-CI-Linux, PowerShell-CI-macOS

Comment thread test/powershell/Host/ConsoleHost.Tests.ps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dash as a parameter crashes PWSH

4 participants