Skip to content
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
4 changes: 4 additions & 0 deletions localization/strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,10 @@ Falling back to NAT networking.</value>
<value>Update failed (exit code: {}).</value>
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
</data>
<data name="MessageUninstallNoArguments" xml:space="preserve">
<value>{} does not take any arguments. To unregister a distribution, use {} instead.</value>
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
</data>
<data name="MessageUninstallFailed" xml:space="preserve">
<value>Uninstall failed (exit code: {}).</value>
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
Expand Down
9 changes: 9 additions & 0 deletions src/windows/common/WslClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,15 @@ int WslMain(_In_ std::wstring_view commandLine)
}
else if (argument == WSL_UNINSTALL_ARG)
{
commandLine = wsl::windows::common::helpers::ConsumeArgument(commandLine, argument);
argument = wsl::windows::common::helpers::ParseArgument(commandLine);
if (!argument.empty())
{
wsl::windows::common::wslutil::PrintMessage(
Localization::MessageUninstallNoArguments(WSL_UNINSTALL_ARG, WSL_UNREGISTER_ARG), stdout);
return exitCode;
}

return Uninstall();
}
else
Expand Down
8 changes: 8 additions & 0 deletions test/windows/UnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6562,5 +6562,13 @@ Error code: Wsl/InstallDistro/WSL_E_INVALID_JSON\r\n",
VERIFY_ARE_EQUAL(result.ExitCode, 0);
}

TEST_METHOD(UninstallRejectsArguments)
{
VerifyOutput(
L"--uninstall Distro",
wsl::shared::Localization::MessageUninstallNoArguments(WSL_UNINSTALL_ARG, WSL_UNREGISTER_ARG) + L"\r\n",
-1);
}

}; // namespace UnitTests
} // namespace UnitTests
Loading