Fix locale issues with WSL version detection

Since wsl --version triggers help, which triggers an error code,
use that instead of text detection.

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
This commit is contained in:
Jason T. Greene 2023-10-03 00:08:31 -05:00
parent 527cf365c1
commit cbca395291
1 changed files with 3 additions and 10 deletions

View File

@ -50,20 +50,13 @@ func IsWSLInstalled() bool {
func IsWSLStoreVersionInstalled() bool {
cmd := SilentExecCmd("wsl", "--version")
out, err := cmd.StdoutPipe()
cmd.Stdout = nil
cmd.Stderr = nil
if err != nil {
return false
}
if err = cmd.Start(); err != nil {
return false
}
hasVersion := matchOutputLine(out, "WSL version:")
if err := cmd.Wait(); err != nil {
if err := cmd.Run(); err != nil {
return false
}
return hasVersion
return true
}
func matchOutputLine(output io.ReadCloser, match string) bool {