Skip to content

Commit 8b6f62a

Browse files
authored
Merge pull request #952 from rumpl/fix-cwd
Fix the CWD in the shell
2 parents c51a41c + 72f6dae commit 8b6f62a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

pkg/tools/builtin/shell.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ func (h *shellHandler) RunShell(ctx context.Context, toolCall tools.ToolCall) (*
151151

152152
cmd := exec.Command(h.shell, append(h.shellArgsPrefix, params.Cmd)...)
153153
cmd.Env = h.env
154-
cmd.Dir = h.workingDir
155-
if params.Cwd != "" {
156-
cmd.Dir = params.Cwd
154+
cmd.Dir = params.Cwd
155+
if params.Cwd == "" || params.Cwd == "." {
156+
cmd.Dir = h.workingDir
157157
}
158158

159159
cmd.SysProcAttr = platformSpecificSysProcAttr()
@@ -231,9 +231,9 @@ func (h *shellHandler) RunShellBackground(ctx context.Context, toolCall tools.To
231231
// Setup command (no context - background jobs run independently)
232232
cmd := exec.Command(h.shell, append(h.shellArgsPrefix, params.Cmd)...)
233233
cmd.Env = h.env
234-
cmd.Dir = h.workingDir
235-
if params.Cwd != "" {
236-
cmd.Dir = params.Cwd
234+
cmd.Dir = params.Cwd
235+
if params.Cwd == "" || params.Cwd == "." {
236+
cmd.Dir = h.workingDir
237237
}
238238

239239
cmd.SysProcAttr = platformSpecificSysProcAttr()

0 commit comments

Comments
 (0)