From 751b50e071174981da329d530505971e18e21dde Mon Sep 17 00:00:00 2001 From: Soarinferret Date: Fri, 24 Nov 2023 18:39:20 -0600 Subject: [PATCH] Fix bug where you cannot use '/usr/bin/env bash' as the shell for systems where bash is in a different location --- agent/agent.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/agent/agent.go b/agent/agent.go index 1cc74cf..67afef2 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -306,7 +306,8 @@ func (a *Agent) CmdV2(c *CmdOptions) CmdStatus { } else if c.IsExecutable { envCmd = gocmd.NewCmdOptions(cmdOptions, c.Shell, c.Command) // c.Shell: bin + c.Command: args as one string } else { - envCmd = gocmd.NewCmdOptions(cmdOptions, c.Shell, "-c", c.Command) // /bin/bash -c 'ls -l /var/log/...' + commandArray := append(strings.Fields(c.Shell), "-c", c.Command) + envCmd = gocmd.NewCmdOptions(cmdOptions, commandArray[0], commandArray[1:]...) // /bin/bash -c 'ls -l /var/log/...' } var stdoutBuf bytes.Buffer