summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKeath Milligan <[email protected]>2025-11-17 01:06:44 -0600
committerGitHub <[email protected]>2025-11-17 01:06:44 -0600
commitf4d892d4e1f42734c5ecc438163ec1dccc2ef7fc (patch)
treee166014871b7fa926e3049e6426d31d5126f7599
parent10b3702938c19a405f504dd0268087f262ab6a99 (diff)
downloadopencode-f4d892d4e1f42734c5ecc438163ec1dccc2ef7fc.tar.gz
opencode-f4d892d4e1f42734c5ecc438163ec1dccc2ef7fc.zip
fix: handle Git Bash path mapping on windows (#4380)
-rw-r--r--packages/opencode/src/tool/bash.ts16
1 files changed, 12 insertions, 4 deletions
diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts
index a3ccfc397..f184d5efe 100644
--- a/packages/opencode/src/tool/bash.ts
+++ b/packages/opencode/src/tool/bash.ts
@@ -89,10 +89,18 @@ export const BashTool = Tool.define("bash", {
.text()
.then((x) => x.trim())
log.info("resolved path", { arg, resolved })
- if (resolved && !Filesystem.contains(Instance.directory, resolved)) {
- throw new Error(
- `This command references paths outside of ${Instance.directory} so it is not allowed to be executed.`,
- )
+ if (resolved) {
+ // Git Bash on Windows returns Unix-style paths like /c/Users/...
+ const normalized =
+ process.platform === "win32" && resolved.match(/^\/[a-z]\//)
+ ? resolved.replace(/^\/([a-z])\//, (_, drive) => `${drive.toUpperCase()}:\\`).replace(/\//g, "\\")
+ : resolved
+
+ if (!Filesystem.contains(Instance.directory, normalized)) {
+ throw new Error(
+ `This command references paths outside of ${Instance.directory} so it is not allowed to be executed.`,
+ )
+ }
}
}
}