Skip to content

Commit

Permalink
Fixes for tracing output with exit code != 0
Browse files Browse the repository at this point in the history
  • Loading branch information
9seconds committed Oct 31, 2014
1 parent 9bdb8ef commit aa38b44
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/commands/tee.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"io/ioutil"
"os"
"os/exec"
"regexp"

"github.com/9seconds/ah/app/environments"
Expand All @@ -27,10 +28,7 @@ func Tee(input string, interactive bool, pseudoTTY bool, env *environments.Envir
combinedStdout := io.MultiWriter(os.Stdout, gzippedWrapper)
combinedStderr := io.MultiWriter(os.Stderr, gzippedWrapper)

commandError := utils.Exec(input,
env.GetShell(), interactive, pseudoTTY,
os.Stdin, combinedStdout, combinedStderr)

var commandError *exec.ExitError
defer func() {
// defer here because command may cause a panic but we do not want to lose any output
gzippedWrapper.Close()
Expand All @@ -45,11 +43,15 @@ func Tee(input string, interactive bool, pseudoTTY bool, env *environments.Envir
} else {
utils.Logger.Errorf("Error occured on fetching command number: %v", err)
}

if commandError != nil {
os.Exit(utils.GetStatusCode(commandError))
}
}()

if commandError != nil {
os.Exit(utils.GetStatusCode(commandError))
}
commandError = utils.Exec(input,
env.GetShell(), interactive, pseudoTTY,
os.Stdin, combinedStdout, combinedStderr)
}

func getPreciseHash(cmd string, env *environments.Environment) (hash string, err error) {
Expand Down

0 comments on commit aa38b44

Please sign in to comment.