Skip to content

Commit

Permalink
Use exec syscall vs pipes and subprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
lox committed Sep 15, 2015
1 parent 7efc5f3 commit efa688a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"os"
"os/exec"
"syscall"
"time"

"github.com/99designs/aws-vault/keyring"
Expand Down Expand Up @@ -44,13 +45,14 @@ func ExecCommand(ui Ui, input ExecCommandInput) {
env = append(env, "AWS_SESSION_TOKEN="+val.SessionToken)
}

cmd := exec.Command(input.Command, input.Args...)
cmd.Env = env
cmd.Stdin = os.Stdin
cmd.Stdout = &logWriter{ui.Logger}
cmd.Stderr = &logWriter{ui.Error}
path, err := exec.LookPath(input.Command)
if err != nil {
ui.Error.Fatal(err)
}

argv := append([]string{input.Command}, input.Args...)

if err := cmd.Run(); err != nil {
if err := syscall.Exec(path, argv, env); err != nil {
ui.Error.Fatal(err)
}
}

0 comments on commit efa688a

Please sign in to comment.