fix: use cmd /c on Windows for shell command execution
The exec tool was hardcoded to use 'sh -c' which doesn't exist on Windows, causing all tool calls to fail silently in gateway mode.
This commit is contained in:
parent
1d143fa10a
commit
53c69ae41e
1 changed files with 8 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -91,7 +92,12 @@ func (t *ExecTool) Execute(ctx context.Context, args map[string]interface{}) (st
|
||||||
cmdCtx, cancel := context.WithTimeout(ctx, t.timeout)
|
cmdCtx, cancel := context.WithTimeout(ctx, t.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
cmd := exec.CommandContext(cmdCtx, "sh", "-c", command)
|
var cmd *exec.Cmd
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
cmd = exec.CommandContext(cmdCtx, "cmd", "/c", command)
|
||||||
|
} else {
|
||||||
|
cmd = exec.CommandContext(cmdCtx, "sh", "-c", command)
|
||||||
|
}
|
||||||
if cwd != "" {
|
if cwd != "" {
|
||||||
cmd.Dir = cwd
|
cmd.Dir = cwd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue