mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
fix: convert exitErr to commandError if runCommand fails
exitError must not exit the runCommand helper, only commandError safety check when casting in segment_language
This commit is contained in:
parent
f8b28f01ba
commit
31c77af58f
|
@ -170,7 +170,12 @@ func (env *environment) runCommand(command string, args ...string) (string, erro
|
||||||
}
|
}
|
||||||
out, err := exec.Command(command, args...).Output()
|
out, err := exec.Command(command, args...).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||||
|
return "", &commandError{
|
||||||
|
err: exitErr.Error(),
|
||||||
|
exitCode: exitErr.ExitCode(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return strings.TrimSpace(string(out)), nil
|
return strings.TrimSpace(string(out)), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,9 +77,10 @@ func (l *language) getVersion() bool {
|
||||||
l.exitCode = 0
|
l.exitCode = 0
|
||||||
l.version = values["version"]
|
l.version = values["version"]
|
||||||
} else {
|
} else {
|
||||||
errors.As(err, &exerr)
|
|
||||||
l.exitCode = exerr.exitCode
|
|
||||||
l.version = ""
|
l.version = ""
|
||||||
|
if errors.As(err, &exerr) {
|
||||||
|
l.exitCode = exerr.exitCode
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue