Skip to content

Commit ee3cee7

Browse files
committed
fix: exec workdir with leading ~ falls back and still executes command
1 parent aea208f commit ee3cee7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/agents/bash-tools.shared.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import fs from "node:fs/promises";
88
import { homedir } from "node:os";
99
import path from "node:path";
1010
import { parseStrictInteger } from "@openclaw/normalization-core/number-coercion";
11+
import { expandHomePrefix } from "../infra/home-dir.js";
1112
import { sliceUtf16Safe } from "../utils.js";
1213
import { assertSandboxPath } from "./sandbox-paths.js";
1314
import type { SandboxBackendExecSpec } from "./sandbox/backend-handle.types.js";
@@ -183,10 +184,11 @@ function normalizeContainerPath(input: string): string {
183184
export function resolveWorkdir(workdir: string, warnings: string[]) {
184185
const current = safeCwd();
185186
const fallback = current ?? homedir();
187+
const expanded = expandHomePrefix(workdir);
186188
try {
187-
const stats = statSync(workdir);
189+
const stats = statSync(expanded);
188190
if (stats.isDirectory()) {
189-
return workdir;
191+
return expanded;
190192
}
191193
} catch {
192194
// ignore, fallback below

0 commit comments

Comments
 (0)