mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 20:39:40 -08:00
fix: wait for command to complete
without wait(), the *ProcessState is nil, meaning we can't access the ExitCode(). On Windows, calling wait() introduces a timeout which makes things run slower, which is why we only call wait() in case of an error. That should not be the main use-case. relates to #285
This commit is contained in:
parent
7e7483501c
commit
d9d2430ae9
|
@ -201,6 +201,9 @@ func (env *environment) runCommand(command string, args ...string) (string, erro
|
||||||
stdoutString := getOutputString(stdout)
|
stdoutString := getOutputString(stdout)
|
||||||
stderrString := getOutputString(stderr)
|
stderrString := getOutputString(stderr)
|
||||||
if stderrString != "" {
|
if stderrString != "" {
|
||||||
|
// only wait in case of error reduces the lead time on successful
|
||||||
|
// commands on windows due to not calling process.Wait()
|
||||||
|
_ = cmd.Wait()
|
||||||
return "", &commandError{
|
return "", &commandError{
|
||||||
err: stderrString,
|
err: stderrString,
|
||||||
exitCode: cmd.ProcessState.ExitCode(),
|
exitCode: cmd.ProcessState.ExitCode(),
|
||||||
|
|
Loading…
Reference in a new issue