Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
TravisEz13 merged 1 commit into
PowerShell:masterPowerShell/PowerShell:masterfrom
SteveL-MSFT:dash-argSteveL-MSFT/PowerShell:dash-argCopy head branch name to clipboard
Apr 27, 2019
Merged

Allow passing just a dash as an arg to a file via pwsh#9479
TravisEz13 merged 1 commit into
PowerShell:masterPowerShell/PowerShell:masterfrom
SteveL-MSFT:dash-argSteveL-MSFT/PowerShell:dash-argCopy head branch name to clipboard

Conversation

@SteveL-MSFT

@SteveL-MSFT 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

@TravisEz13 TravisEz13 added this to the 7.0.0-preview.1 milestone Apr 26, 2019
@TravisEz13 TravisEz13 added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Apr 26, 2019
@SteveL-MSFT

Copy link
Copy Markdown
Member Author

@PoshChan please retry linux, macos

@PoshChan

Copy link
Copy Markdown
Collaborator

@SteveL-MSFT, successfully started retry of PowerShell-CI-Linux, PowerShell-CI-macOS

Comment thread test/powershell/Host/ConsoleHost.Tests.ps1
@TravisEz13 TravisEz13 merged commit d318e77 into PowerShell:master Apr 27, 2019
@iSazonov iSazonov assigned TravisEz13 and unassigned iSazonov Apr 27, 2019
@SteveL-MSFT SteveL-MSFT deleted the dash-arg branch April 29, 2019 17:41
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.