Skip to content

Instantly share code, notes, and snippets.

@rjeczalik
Created November 18, 2014 09:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjeczalik/113d1dd2b5b29e4c1452 to your computer and use it in GitHub Desktop.
Save rjeczalik/113d1dd2b5b29e4c1452 to your computer and use it in GitHub Desktop.
go-exec: debugging os/exec with interactive scripts
package main
import (
"fmt"
"os"
"os/exec"
)
func die(v interface{}) {
fmt.Fprintln(os.Stderr, v)
os.Exit(1)
}
func main() {
if len(os.Args) == 1 {
die("usage: go-exec COMMAND [ARG...]")
}
cmd := exec.Command(os.Args[1], os.Args[2:]...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
die(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment