8000 Write an error for powershell -version <any value> by iSazonov · Pull Request #4931 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 5 commits into from
Sep 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@ private void ParseHelper(string[] args)
_noInteractive = true;
_skipUserInit = true;
_noExit = false;

++i;
if (i < args.Length)
{
WriteCommandLineError(string.Format(CultureInfo.CurrentCulture, CommandLineParameterParserStrings.DeprecatedVersionParameter,args[i]));
}
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>Usage of '-Version {0}' is not supported. '-Version' currently only returns the current PowerShell version.</value>
</data>
</root>
9 changes: 9 additions & 0 deletions test/powershell/Host/ConsoleHost.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ Describe "ConsoleHost unit tests" -tags "Feature" {
$observed | should be $currentVersion
}

It "-Version should write an error if a value is present" {
$versionValue = "abrakadabra"
$tempFile = Join-Path $testdrive "expectedError.txt"
$observed = & $powershell -version $versionValue > $tempFile
$expectedError = (Get-Content $tempFile)[0]

$expectedError | Should Match $versionValue
}

It "-File should be default parameter" {
Set-Content -Path $testdrive/test -Value "'hello'"
$observed = & $powershell -NoProfile $testdrive/test
Expand Down
0