Write an error for powershell -version <any value>#4931
Write an error for powershell -version <any value>#4931iSazonov merged 5 commits intoPowerShell:masterfrom
Conversation
| <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.
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.
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.
I think we should currently error if any value is passed to -v
There was a problem hiding this comment.
Now we write the error and then show current version.
Please clarify your request.
There was a problem hiding this comment.
Aren't you only writing error if -v 2? Should also error if -v 3
There was a problem hiding this comment.
I agree. Will add the error for -v 3 too.
There was a problem hiding this comment.
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.
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.
Could you comment #4836 - I am ready to implement enumeration of installed versioms.
There was a problem hiding this comment.
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.
It is an enhancement. It make sense. Thanks!
Done.
3d9f9b8 to
5a15659
Compare
| ++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.
I think we should error on any value passed to -v as part of this PR.
Fix #4834