@@ -17,7 +17,7 @@ import (
1717 "strings"
1818 "sync"
1919
20- "github.com/google/shlex "
20+ "github.com/buildkite/shellwords "
2121 "github.com/gptscript-ai/gptscript/pkg/counter"
2222 "github.com/gptscript-ai/gptscript/pkg/env"
2323 "github.com/gptscript-ai/gptscript/pkg/types"
@@ -118,7 +118,7 @@ func (e *Engine) runCommand(ctx Context, tool types.Tool, input string, toolCate
118118 instructions = append (instructions , inputContext .Content )
119119 }
120120
121- var extraEnv = []string {
121+ extraEnv : = []string {
122122 strings .TrimSpace ("GPTSCRIPT_CONTEXT=" + strings .Join (instructions , "\n " )),
123123 }
124124 cmd , stop , err := e .newCommand (ctx .Ctx , extraEnv , tool , input )
@@ -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 := shellwords .Split (interpreter )
258258 if err != nil {
259259 return nil , nil , err
260260 }
@@ -332,15 +332,15 @@ func replaceVariablesForInterpreter(interpreter string, envMap map[string]string
332332 return envMap [s ]
333333 })
334334 // We protect newly resolved env vars from getting replaced when we do the second Expand
335- // after shlex . Yeah, crazy. I'm guessing this isn't secure, but just trying to avoid a foot gun.
335+ // after shellwords . Yeah, crazy. I'm guessing this isn't secure, but just trying to avoid a foot gun.
336336 part = os .Expand (part , func (s string ) string {
337337 return "${__" + s + "}"
338338 })
339339 }
340340 parts = append (parts , part )
341341 }
342342
343- parts , err := shlex .Split (strings .Join (parts , "" ))
343+ parts , err := shellwords .Split (strings .Join (parts , "" ))
344344 if err != nil {
345345 return nil , err
346346 }
0 commit comments