Repository navigation
Get-Command should not throw with white space argument #10157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4cbb73b
e9846e8
03a6946
47df1d1
c248f60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| Describe "Get-Command Tests" -Tags "CI" { | ||
| BeforeAll { | ||
| function TestGetCommand-DynamicParametersDCR | ||
|
|
@@ -28,7 +29,7 @@ Describe "Get-Command Tests" -Tags "CI" { | |
| "return1" { | ||
| $attr = [System.Management.Automation.ParameterAttribute]::new() | ||
| $attr.Mandatory = $true | ||
| $dynamicParameter = [System.Management.Automation.RuntimeDefinedParameter]::new("OneString",[string],$attr) | ||
| $dynamicParameter = [System.Management.Automation.RuntimeDefinedParameter]::new("OneString",[string],$attr) | ||
| $dynamicParamDictionary.Add("OneString",$dynamicParameter) | ||
| break | ||
| } | ||
|
|
@@ -263,4 +264,8 @@ Describe "Get-Command Tests" -Tags "CI" { | |
| VerifyDynamicParametersExist -cmdlet $results[0] -parameterNames $paramName | ||
| VerifyParameterType -cmdlet $results[0] -parameterName $paramName -ParameterType System.Text.Encoding | ||
| } | ||
|
|
||
| It "Get-Command `" `" does not throw" -Pending { | ||
| Get-Command " " | Should -Not -Throw | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the expected behavior that it should not throw, or that it should throw in a specific way? (i.e. throws
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that it is possible to create an alias that contains a single whitespace (see #10165),
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guys,, do you really use whitespaces commands in your scripts and consider it a great practice? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I stumbled upon this due to a bug in my own script; when a user enters invalid input PowerShell should respond appropriately so that the user knows what they did wrong.
While I don't have any thoughts as to whether the behavior described in #10165 should be allowed, I would present that the resolution of #10165 issue should not impact the resolution of #10148; a command either exists or it doesn't -
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Of course not. That doesn't change the fact that it can be done though, and I'm still with lordmilko: the error should be |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.