fix(cmd): only fetch =ExitCode on no status

This commit is contained in:
Jan De Dobbeleer 2023-12-02 20:10:44 +01:00 committed by Jan De Dobbeleer
parent 1bdc22bf40
commit d588965e50

View file

@ -630,15 +630,13 @@ func (env *Shell) HasCommand(command string) bool {
func (env *Shell) StatusCodes() (int, string) {
defer env.Trace(time.Now())
if env.CmdFlags.Shell != CMD || env.CmdFlags.ErrorCode == 0 {
if env.CmdFlags.Shell != CMD || !env.CmdFlags.NoExitCode {
return env.CmdFlags.ErrorCode, env.CmdFlags.PipeStatus
}
errorCode := env.Getenv("=ExitCode")
if len(errorCode) > 0 {
env.Debug(errorCode)
env.CmdFlags.ErrorCode, _ = strconv.Atoi(errorCode)
}
env.Debug(errorCode)
env.CmdFlags.ErrorCode, _ = strconv.Atoi(errorCode)
return env.CmdFlags.ErrorCode, env.CmdFlags.PipeStatus
}