summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-08-03 10:30:00 -0400
committerDax Raad <[email protected]>2025-08-03 10:30:23 -0400
commit7e763e1c06bba82fbf37dbb67757765efbcdcab1 (patch)
tree0ef460301f106768dc171d53ee740215ea58b282
parentb0f2cc0c22c3a977b47888df3b2ba6d103a50973 (diff)
downloadopencode-7e763e1c06bba82fbf37dbb67757765efbcdcab1.tar.gz
opencode-7e763e1c06bba82fbf37dbb67757765efbcdcab1.zip
fix shell error 128
-rw-r--r--packages/opencode/src/tool/bash.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts
index 629201e37..8688aa707 100644
--- a/packages/opencode/src/tool/bash.ts
+++ b/packages/opencode/src/tool/bash.ts
@@ -75,9 +75,13 @@ export const BashTool = Tool.define("bash", {
if (["cd", "rm", "cp", "mv", "mkdir", "touch", "chmod", "chown"].includes(command[0])) {
for (const arg of command.slice(1)) {
if (arg.startsWith("-") || (command[0] === "chmod" && arg.startsWith("+"))) continue
- const resolved = await $`realpath ${arg}`.text().then((x) => x.trim())
+ const resolved = await $`realpath ${arg}`
+ .quiet()
+ .nothrow()
+ .text()
+ .then((x) => x.trim())
log.info("resolved path", { arg, resolved })
- if (!Filesystem.contains(app.path.cwd, resolved)) {
+ if (resolved && !Filesystem.contains(app.path.cwd, resolved)) {
throw new Error(
`This command references paths outside of ${app.path.cwd} so it is not allowed to be executed.`,
)