diff --git a/go.mod b/go.mod index c84dae97..a1ea1cfa 100644 --- a/go.mod +++ b/go.mod @@ -7,12 +7,12 @@ require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 github.com/adrg/xdg v0.4.0 + github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be github.com/chzyer/readline v1.5.1 github.com/docker/cli v26.0.0+incompatible github.com/docker/docker-credential-helpers v0.8.1 github.com/fatih/color v1.17.0 github.com/getkin/kin-openapi v0.124.0 - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/uuid v1.6.0 github.com/gptscript-ai/broadcaster v0.0.0-20240625175512-c43682019b86 github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf0379 diff --git a/go.sum b/go.sum index 7e2d7b75..2323957c 100644 --- a/go.sum +++ b/go.sum @@ -50,6 +50,8 @@ github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= @@ -153,8 +155,6 @@ github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OI github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= diff --git a/pkg/engine/cmd.go b/pkg/engine/cmd.go index 311c743a..ad6250a2 100644 --- a/pkg/engine/cmd.go +++ b/pkg/engine/cmd.go @@ -17,7 +17,7 @@ import ( "strings" "sync" - "github.com/google/shlex" + "github.com/anmitsu/go-shlex" "github.com/gptscript-ai/gptscript/pkg/counter" "github.com/gptscript-ai/gptscript/pkg/env" "github.com/gptscript-ai/gptscript/pkg/types" @@ -254,7 +254,7 @@ func (e *Engine) newCommand(ctx context.Context, extraEnv []string, tool types.T interpreter, rest, _ := strings.Cut(tool.Instructions, "\n") interpreter = strings.TrimSpace(interpreter)[2:] - args, err := shlex.Split(interpreter) + args, err := shlex.Split(interpreter, runtime.GOOS != "windows") if err != nil { return nil, nil, err } @@ -340,7 +340,7 @@ func replaceVariablesForInterpreter(interpreter string, envMap map[string]string parts = append(parts, part) } - parts, err := shlex.Split(strings.Join(parts, "")) + parts, err := shlex.Split(strings.Join(parts, ""), runtime.GOOS != "windows") if err != nil { return nil, err } diff --git a/pkg/types/tool.go b/pkg/types/tool.go index bb49e6f1..84ede07d 100644 --- a/pkg/types/tool.go +++ b/pkg/types/tool.go @@ -5,12 +5,13 @@ import ( "encoding/json" "fmt" "path/filepath" + "runtime" "slices" "sort" "strings" + "github.com/anmitsu/go-shlex" "github.com/getkin/kin-openapi/openapi3" - "github.com/google/shlex" "github.com/gptscript-ai/gptscript/pkg/system" "golang.org/x/exp/maps" ) @@ -257,7 +258,7 @@ func ParseCredentialArgs(toolName string, input string) (string, string, map[str _ = json.Unmarshal([]byte(input), &inputMap) } - fields, err := shlex.Split(toolName) + fields, err := shlex.Split(toolName, runtime.GOOS != "windows") if err != nil { return "", "", nil, err }