James Ring | e5e9bd3 | 2014-12-10 12:48:28 -0800 | [diff] [blame^] | 1 | package core |
| 2 | |
| 3 | import ( |
| 4 | "io" |
| 5 | "os/exec" |
| 6 | |
| 7 | "veyron.io/veyron/veyron/lib/modules" |
| 8 | ) |
| 9 | |
| 10 | func init() { |
| 11 | modules.RegisterChild(ExecCommand, "", execCommand) |
| 12 | } |
| 13 | |
| 14 | func execCommand(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error { |
| 15 | cmd := exec.Command(args[1], args[2:]...) |
| 16 | envSlice := []string{} |
| 17 | for key, value := range env { |
| 18 | envSlice = append(envSlice, key+"="+value) |
| 19 | } |
| 20 | |
| 21 | cmd.Env = envSlice |
| 22 | cmd.Stdin = stdin |
| 23 | cmd.Stdout = stdout |
| 24 | cmd.Stderr = stderr |
| 25 | return cmd.Run() |
| 26 | } |