Skip to content

Commit

Permalink
add support to exec shell commands with args
Browse files Browse the repository at this point in the history
  • Loading branch information
speier committed Nov 3, 2024
1 parent 4098092 commit 7cbcc54
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/exec/shell_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"runtime"
"slices"
"strings"

"mvdan.cc/sh/v3/expand"
Expand All @@ -28,7 +29,10 @@ func ExecuteShellCommand(
dryRun bool,
redirectStdError string,
) error {
cmd := exec.Command(command, args...)
cmdParts := strings.Split(command, " ")
cmdName := cmdParts[0]
cmdArgs := slices.Concat(cmdParts[1:], args)
cmd := exec.Command(cmdName, cmdArgs...)
cmd.Env = append(os.Environ(), env...)
cmd.Dir = dir
cmd.Stdin = os.Stdin
Expand Down

0 comments on commit 7cbcc54

Please sign in to comment.