diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2024-12-27 02:16:14 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2024-12-27 02:16:14 +0100 |
commit | 280114a5d3a756b820ce74426aa628cf938ccbf4 (patch) | |
tree | 65b1a58a95f0563907f005ffd40bace6eb12e185 /acid.go | |
parent | d83517f67ba638abed1d76541068413e60142194 (diff) | |
download | acid-280114a5d3a756b820ce74426aa628cf938ccbf4.tar.gz acid-280114a5d3a756b820ce74426aa628cf938ccbf4.tar.xz acid-280114a5d3a756b820ce74426aa628cf938ccbf4.zip |
Unify our usage of the local shell
Diffstat (limited to 'acid.go')
-rw-r--r-- | acid.go | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -154,6 +154,14 @@ var shellFuncs = ttemplate.FuncMap{ // --- Utilities --------------------------------------------------------------- +func localShell() string { + if shell := os.Getenv("SHELL"); shell != "" { + return shell + } + // The os/user package doesn't store the parsed out shell field. + return "/bin/sh" +} + func giteaSign(b []byte) string { payloadHmac := hmac.New(sha256.New, []byte(getConfig().Secret)) payloadHmac.Write(b) @@ -842,7 +850,7 @@ func notifierRunCommand(ctx context.Context, task Task) { return } - cmd := exec.CommandContext(ctx, "sh") + cmd := exec.CommandContext(ctx, localShell()) cmd.Stdin = script cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr @@ -1166,14 +1174,6 @@ func executorDownload(client *ssh.Client, remoteRoot, localRoot string) error { return nil } -func executorLocalShell() string { - if shell := os.Getenv("SHELL"); shell != "" { - return shell - } - // The os/user package doesn't store the parsed out shell field. - return "/bin/sh" -} - func executorTmpDir(fallback string) string { // See also: https://systemd.io/TEMPORARY_DIRECTORIES/ if tmp := os.Getenv("TMPDIR"); tmp != "" { @@ -1209,9 +1209,10 @@ func executorDeploy( return err } - cmd := exec.CommandContext(ctx, executorLocalShell(), "-c", script.String()) + cmd := exec.CommandContext(ctx, localShell()) cmd.Env = rt.localEnv() cmd.Dir = dir + cmd.Stdin = script cmd.Stdout = &rt.DeployLog cmd.Stderr = &rt.DeployLog return cmd.Run() |