diff options
author | Thomas Boerger <thomas@webhippie.de> | 2016-11-27 12:11:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-27 12:11:04 +0100 |
commit | bc59b8abc9b63b90cd0774680d94c3f70ac85a1a (patch) | |
tree | 8c88972f63d822997e964db1f445074391a3a54f | |
parent | 3ac72255fa66df42811ff04dc1b3bf833a3f84ec (diff) | |
parent | 9aaf2a6d9a33416ed55798a7eb60f78bd9195352 (diff) | |
download | gitea-bc59b8abc9b63b90cd0774680d94c3f70ac85a1a.tar.gz gitea-bc59b8abc9b63b90cd0774680d94c3f70ac85a1a.zip |
Merge pull request #273 from typeless/master
modules/process: add ExecDirEnv (next to ExecDir)
-rw-r--r-- | modules/process/manager.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/process/manager.go b/modules/process/manager.go index 2748c14bb4..0d5416ec13 100644 --- a/modules/process/manager.go +++ b/modules/process/manager.go @@ -52,11 +52,11 @@ func Add(desc string, cmd *exec.Cmd) int64 { return pid } -// ExecDir runs a command in given path and waits for its completion +// ExecDirEnv runs a command in given path and environment variables, and waits for its completion // up to the given timeout (or DefaultTimeout if -1 is given). // Returns its complete stdout and stderr // outputs and an error, if any (including timeout) -func ExecDir(timeout time.Duration, dir, desc, cmdName string, args ...string) (string, string, error) { +func ExecDirEnv(timeout time.Duration, dir, desc string, env []string, cmdName string, args ...string) (string, string, error) { if timeout == -1 { timeout = DefaultTimeout } @@ -66,6 +66,7 @@ func ExecDir(timeout time.Duration, dir, desc, cmdName string, args ...string) ( cmd := exec.Command(cmdName, args...) cmd.Dir = dir + cmd.Env = env cmd.Stdout = bufOut cmd.Stderr = bufErr if err := cmd.Start(); err != nil { @@ -93,6 +94,11 @@ func ExecDir(timeout time.Duration, dir, desc, cmdName string, args ...string) ( return bufOut.String(), bufErr.String(), err } +// ExecDir works exactly like ExecDirEnv except no environment variable is provided. +func ExecDir(timeout time.Duration, dir, desc, cmdName string, args ...string) (string, string, error) { + return ExecDirEnv(timeout, dir, desc, nil, cmdName, args...) +} + // ExecTimeout runs a command and waits for its completion // up to the given timeout (or DefaultTimeout if -1 is given). // Returns its complete stdout and stderr |