Skip to content

Commit 7e54289

Browse files
committed
fix: use a different shlex
The shlex splitting was ruining Windows paths. The new shlex is nicer to Windows. Signed-off-by: Donnie Adams <[email protected]>
1 parent 9e770b9 commit 7e54289

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ require (
77
github.com/AlecAivazis/survey/v2 v2.3.7
88
github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69
99
github.com/adrg/xdg v0.4.0
10+
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be
1011
github.com/chzyer/readline v1.5.1
1112
github.com/docker/cli v26.0.0+incompatible
1213
github.com/docker/docker-credential-helpers v0.8.1
1314
github.com/fatih/color v1.17.0
1415
github.com/getkin/kin-openapi v0.124.0
15-
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
1616
github.com/google/uuid v1.6.0
1717
github.com/gptscript-ai/broadcaster v0.0.0-20240625175512-c43682019b86
1818
github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf0379

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk
5050
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
5151
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
5252
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
53+
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
54+
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
5355
github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk=
5456
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
5557
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
153155
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
154156
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
155157
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
156-
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
157-
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
158158
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
159159
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
160160
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=

pkg/engine/cmd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"strings"
1818
"sync"
1919

20-
"github.com/google/shlex"
20+
"github.com/anmitsu/go-shlex"
2121
"github.com/gptscript-ai/gptscript/pkg/counter"
2222
"github.com/gptscript-ai/gptscript/pkg/env"
2323
"github.com/gptscript-ai/gptscript/pkg/types"
@@ -254,7 +254,7 @@ func (e *Engine) newCommand(ctx context.Context, extraEnv []string, tool types.T
254254
interpreter, rest, _ := strings.Cut(tool.Instructions, "\n")
255255
interpreter = strings.TrimSpace(interpreter)[2:]
256256

257-
args, err := shlex.Split(interpreter)
257+
args, err := shlex.Split(interpreter, runtime.GOOS != "windows")
258258
if err != nil {
259259
return nil, nil, err
260260
}
@@ -340,7 +340,7 @@ func replaceVariablesForInterpreter(interpreter string, envMap map[string]string
340340
parts = append(parts, part)
341341
}
342342

343-
parts, err := shlex.Split(strings.Join(parts, ""))
343+
parts, err := shlex.Split(strings.Join(parts, ""), runtime.GOOS != "windows")
344344
if err != nil {
345345
return nil, err
346346
}

pkg/types/tool.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55
"encoding/json"
66
"fmt"
77
"path/filepath"
8+
"runtime"
89
"slices"
910
"sort"
1011
"strings"
1112

13+
"github.com/anmitsu/go-shlex"
1214
"github.com/getkin/kin-openapi/openapi3"
13-
"github.com/google/shlex"
1415
"github.com/gptscript-ai/gptscript/pkg/system"
1516
"golang.org/x/exp/maps"
1617
)
@@ -257,7 +258,7 @@ func ParseCredentialArgs(toolName string, input string) (string, string, map[str
257258
_ = json.Unmarshal([]byte(input), &inputMap)
258259
}
259260

260-
fields, err := shlex.Split(toolName)
261+
fields, err := shlex.Split(toolName, runtime.GOOS != "windows")
261262
if err != nil {
262263
return "", "", nil, err
263264
}

0 commit comments

Comments
 (0)