Skip to content

Commit 16fd77e

Browse files
committed
fix(wsl): Allow cmd.exe to output stderr and return a value.
Signed-off-by: Greg Althaus <[email protected]>
1 parent 1441bd4 commit 16fd77e

File tree

1 file changed

+5
-4
lines changed
  • builder/hyperv/common/wsl

1 file changed

+5
-4
lines changed

builder/hyperv/common/wsl/wsl.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,19 @@ func GetWSlTemp() (string, error) {
4242
err := command.Run()
4343

4444
stderrString := strings.TrimSpace(stderr.String())
45+
stdoutString := strings.TrimSpace(stdout.String())
4546

4647
if _, ok := err.(*exec.ExitError); ok {
47-
err = fmt.Errorf("Error getting wsl TEMP dir: %s", stderrString)
48+
err = fmt.Errorf("Error getting wsl TEMP dir (exec): %s", stderrString)
4849
return "", err
4950
}
5051

51-
if len(stderrString) > 0 {
52-
err = fmt.Errorf("Error getting wsl TEMP dir: %s", stderrString)
52+
if len(stdoutString) == 0 && len(stderrString) > 0 {
53+
err = fmt.Errorf("Error getting wsl TEMP dir (stderr): \"%s\", %s", stdoutString, stderrString)
5354
return "", err
5455
}
5556

56-
return strings.TrimSpace(stdout.String()), err
57+
return stdoutString, err
5758
}
5859

5960
func ConvertWindowsPathToWSlPath(winPath string) (string, error) {

0 commit comments

Comments
 (0)