mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-10 03:14:55 +01:00
fix shell error 128
This commit is contained in:
@@ -75,9 +75,13 @@ export const BashTool = Tool.define("bash", {
|
|||||||
if (["cd", "rm", "cp", "mv", "mkdir", "touch", "chmod", "chown"].includes(command[0])) {
|
if (["cd", "rm", "cp", "mv", "mkdir", "touch", "chmod", "chown"].includes(command[0])) {
|
||||||
for (const arg of command.slice(1)) {
|
for (const arg of command.slice(1)) {
|
||||||
if (arg.startsWith("-") || (command[0] === "chmod" && arg.startsWith("+"))) continue
|
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 })
|
log.info("resolved path", { arg, resolved })
|
||||||
if (!Filesystem.contains(app.path.cwd, resolved)) {
|
if (resolved && !Filesystem.contains(app.path.cwd, resolved)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`This command references paths outside of ${app.path.cwd} so it is not allowed to be executed.`,
|
`This command references paths outside of ${app.path.cwd} so it is not allowed to be executed.`,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user