diff options
Diffstat (limited to 'lib/hooks/exec.go')
-rw-r--r-- | lib/hooks/exec.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/hooks/exec.go b/lib/hooks/exec.go new file mode 100644 index 00000000..bea35f32 --- /dev/null +++ b/lib/hooks/exec.go @@ -0,0 +1,22 @@ +package hooks + +import ( + "os" + "os/exec" + + "git.sr.ht/~rjarry/aerc/log" +) + +func RunHook(h HookType) error { + cmd := h.Cmd() + if cmd == "" { + return nil + } + env := h.Env() + log.Debugf("hooks: running command %q (env %v)", cmd, env) + + proc := exec.Command("sh", "-c", cmd) + proc.Env = os.Environ() + proc.Env = append(proc.Env, env...) + return proc.Run() +} |