diff options
author | Bryan McNulty <bryanmcnulty@protonmail.com> | 2025-04-17 12:28:23 -0500 |
---|---|---|
committer | Bryan McNulty <bryanmcnulty@protonmail.com> | 2025-04-17 12:28:23 -0500 |
commit | 7afebcd5347a2b982d27ac59a59c85dcaf275311 (patch) | |
tree | 7f97c3253e7604233a554b66e3ece179585ba43e /pkg | |
parent | 7fa9b35e4ba0eb477dad9258b827766a65c28fef (diff) | |
download | goexec-7afebcd5347a2b982d27ac59a59c85dcaf275311.tar.gz goexec-7afebcd5347a2b982d27ac59a59c85dcaf275311.zip |
Executable paths with spaces should be quoted in full command string
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/goexec/io.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/pkg/goexec/io.go b/pkg/goexec/io.go index 6bfb76e..4fa7cb8 100644 --- a/pkg/goexec/io.go +++ b/pkg/goexec/io.go @@ -41,6 +41,13 @@ func (execIO *ExecutionIO) GetOutput(ctx context.Context) (err error) { return nil } +func (execIO *ExecutionIO) Clean(ctx context.Context) (err error) { + if execIO.Output.Provider != nil { + return execIO.Output.Provider.Clean(ctx) + } + return nil +} + func (execIO *ExecutionIO) CommandLine() (cmd []string) { if execIO.Output.Provider != nil && execIO.Output.RemotePath != "" { return []string{ @@ -51,13 +58,6 @@ func (execIO *ExecutionIO) CommandLine() (cmd []string) { return execIO.Input.CommandLine() } -func (execIO *ExecutionIO) Clean(ctx context.Context) (err error) { - if execIO.Output.Provider != nil { - return execIO.Output.Provider.Clean(ctx) - } - return nil -} - func (execIO *ExecutionIO) String() (cmd string) { return strings.Join(execIO.CommandLine(), " ") } @@ -76,6 +76,12 @@ func (i *ExecutionInput) CommandLine() (cmd []string) { case i.Executable != "": cmd[0] = i.Executable } + + // Ensure that executable paths are quoted + if strings.Contains(cmd[0], " ") { + cmd[0] = fmt.Sprintf(`%q`, cmd[0]) + } + return cmd } |