-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Write an error for powershell -version <any value> #4931
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
Conversation
@@ -272,4 +272,7 @@ EXAMPLES | |||
<data name="InvalidArgument" xml:space="preserve"> | |||
<value>Invalid argument '{0}', did you mean:</value> | |||
</data> | |||
<data name="DeprecatedVersionParameter" xml:space="preserve"> | |||
<value>Old functionality of '-version 2.0' is deprecated. Now '-version' parameter shows current PowerShell version. </value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should change this error message to:
Previous usage of '-version {0}' is not supported. '-version' currently only supports returning the current PowerShell version.
cc @joeyaiello
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the error message - please review.
++i; | ||
if (i < args.Length) | ||
{ | ||
if (LanguagePrimitives.TryConvertTo<int>(args[i], out int verNumber) && verNumber == 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should currently error if any value is passed to -v
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we write the error and then show current version.
Please clarify your request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't you only writing error if -v 2
? Should also error if -v 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Will add the error for -v 3
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should error on any value passed to -v
. In some future time if we decide to support launching different installed versions of PSCore6, we can decide if we want to overload -v
or even introduce a new parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we ignore all values after -v
. The docs says the same: accept only 2.0 or 3.0. If anybody use the parameter the breaking change is related only to 2.0 or 3.0 values - we should write an error for the cases only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you comment #4836 - I am ready to implement enumeration of installed versioms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we currently ignore all values after -v, then it seems logical to write error on any value passed to -v saying that parameter doesn't have any effect.
Having a parameter that quietly does nothing doesn't look good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an enhancement. It make sense. Thanks!
Done.
3d9f9b8
to
5a15659
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests.
++i; | ||
if (i < args.Length) | ||
{ | ||
if (LanguagePrimitives.TryConvertTo<int>(args[i], out int verNumber) && (verNumber == 2 || verNumber == 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should error on any value passed to -v
as part of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Fix #4834