The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 08:30 UTC
fix(shared): keep literal quotes in POSIX PATH directories (#38238)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Simone committed
Nov 17, 2026 at 19:08 UTC
38f7761148fae79048dac35663d9035918e192c5
4 files changed
+38
-31
apps/server/src/provider/AntigravityInstallation.test.ts
+5
-2
@@ -1066,8 +1066,11 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst
1066
const baseDir = yield* fs
1067
.makeTempDirectoryScoped({ prefix: "t3-agy-cli-test-" })
1068
.pipe(Effect.flatMap((directory) => fs.realPath(directory)));
1069
- const cliDirectory = path.join(baseDir, "cli");
1069
+ const cliDirectory = path.join(baseDir, 'cli" ');
1070
yield* fs.makeDirectory(cliDirectory);
1071
+ const siblingDirectory = path.join(baseDir, 'cli"');
1072
+ yield* fs.makeDirectory(siblingDirectory);
1073
+ yield* fs.writeFileString(path.join(siblingDirectory, "agy"), "other cli", { mode: 0o755 });
1074
const cli = path.join(cliDirectory, "antigravity");
1075
const alias = path.join(cliDirectory, "agy");
1076
const other = path.join(cliDirectory, "custom-acp");
@@ -1115,7 +1118,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst
1118
const windowsDirectory = path.join(baseDir, `windows-${name}`);
1119
yield* fs.makeDirectory(windowsDirectory);
1120
yield* fs.writeFileString(path.join(windowsDirectory, name), "cli");
1118
- const selected = yield* windows.resolve("agy", { PATH: windowsDirectory });
1121
+ const selected = yield* windows.resolve("agy", { PATH: `"${windowsDirectory}"` });
1122
expect(selected.harnessPath).toBeNull();
1123
expect((yield* fs.realPath(selected.executablePath)).toLowerCase()).toBe(
1124
(yield* fs.realPath(path.join(windowsDirectory, name))).toLowerCase(),
apps/server/src/provider/AntigravityInstallation.ts
+1
-2
@@ -367,8 +367,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
367
? Object.entries(processEnvironment).findLast(([key]) => key.toUpperCase() === "PATH")?.[1]
368
: processEnvironment.PATH;
369
const candidates: string[] = [];
370
- for (const directory of (pathValue ?? "").split(platform === "win32" ? ";" : ":")) {
371
- const entry = directory.trim().replace(/^"|"$/gu, "");
370
+ for (const entry of (pathValue ?? "").split(platform === "win32" ? ";" : ":")) {
371
if (entry.length === 0) continue;
372
const resolved = yield* commandPath(command, { ...processEnvironment, PATH: entry });
373
if (resolved !== null) candidates.push(resolved);
packages/shared/src/shell.test.ts
+24
-20
@@ -530,31 +530,35 @@ describe("mergePathValues", () => {
530
expect(mergePathValues("/opt/bin :/opt/bin", "/opt/bin :/usr/bin", "linux")).toBe(
531
"/opt/bin :/opt/bin:/usr/bin",
532
);
533
+ expect(mergePathValues('/opt/bin"', "/opt/bin", "linux")).toBe('/opt/bin":/opt/bin');
534
});
535
});
536
537
effectIt.layer(NodeServices.layer)("resolveCommandPath", (it) => {
537
- it.effect("finds executables in a POSIX PATH directory ending in whitespace", () =>
538
- Effect.gen(function* () {
539
- const fs = yield* FileSystem.FileSystem;
540
- const path = yield* Path.Path;
541
- const cwd = yield* fs.makeTempDirectoryScoped({ directory: ".", prefix: "t3-path-" });
542
- const directory = `${cwd}/bin \u00a0`;
543
- yield* fs.makeDirectory(directory);
544
- const executable = `${directory}/audit-command`;
545
- yield* fs.writeFileString(executable, "#!/bin/sh\n");
546
- yield* fs.chmod(executable, 0o755);
547
- const env = { PATH: directory };
538
+ // Windows rejects `"` in file names.
539
+ it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
540
+ "finds executables in a POSIX PATH directory ending in whitespace and quotes",
541
+ () =>
542
+ Effect.gen(function* () {
543
+ const fs = yield* FileSystem.FileSystem;
544
+ const path = yield* Path.Path;
545
+ const cwd = yield* fs.makeTempDirectoryScoped({ directory: ".", prefix: "t3-path-" });
546
+ const directory = `${cwd}/bin \u00a0"`;
547
+ yield* fs.makeDirectory(directory);
548
+ const executable = `${directory}/audit-command`;
549
+ yield* fs.writeFileString(executable, "#!/bin/sh\n");
550
+ yield* fs.chmod(executable, 0o755);
551
+ const env = { PATH: directory };
552
549
- expect(
550
- yield* resolveCommandPath("audit-command", { env }).pipe(
551
- Effect.provideService(HostProcess.Platform, "linux"),
552
- Effect.provideService(CommandResolutionCache, new Map()),
553
- ),
554
- ).toBe(path.join(directory, "audit-command"));
555
- const resolveExecutable = yield* SpawnExecutableResolution;
556
- expect(resolveExecutable("audit-command", "linux", env)).toBe(executable);
557
- }),
553
+ expect(
554
+ yield* resolveCommandPath("audit-command", { env }).pipe(
555
+ Effect.provideService(HostProcess.Platform, "linux"),
556
+ Effect.provideService(CommandResolutionCache, new Map()),
557
+ ),
558
+ ).toBe(path.join(directory, "audit-command"));
559
+ const resolveExecutable = yield* SpawnExecutableResolution;
560
+ expect(resolveExecutable("audit-command", "linux", env)).toBe(executable);
561
+ }),
562
);
563
564
const recordProbes = (env: NodeJS.ProcessEnv) =>
packages/shared/src/shell.ts
+8
-7
@@ -106,7 +106,7 @@ function resolveSpawnExecutableWithNode(
106
}
107
108
for (const pathEntry of (readEnvPath(env) ?? "").split(pathDelimiterForPlatform(platform))) {
109
- const normalizedPathEntry = stripWrappingQuotes(trimPathEntry(pathEntry, platform));
109
+ const normalizedPathEntry = normalizePathEntry(pathEntry, platform);
110
if (normalizedPathEntry.length === 0) continue;
111
for (const candidate of candidates) {
112
const candidatePath = path.join(normalizedPathEntry, candidate);
@@ -453,20 +453,21 @@ export const readEnvironmentFromWindowsShell = Effect.fn("shell.readEnvironmentF
453
},
454
);
455
456
-function stripWrappingQuotes(value: string): string {
457
- return value.replace(/^"+|"+$/g, "");
458
-}
459
-
456
function trimPathEntry(entry: string, platform: NodeJS.Platform): string {
457
return platform === "win32" ? entry.trim() : entry;
458
}
459
460
+// POSIX PATH entries are literal: whitespace and quotes are part of the directory name.
461
+function normalizePathEntry(entry: string, platform: NodeJS.Platform): string {
462
+ return platform === "win32" ? entry.trim().replace(/^"+|"+$/g, "") : entry;
463
+}
464
+
465
function pathDelimiterForPlatform(platform: NodeJS.Platform): string {
466
return platform === "win32" ? WINDOWS_PATH_DELIMITER : POSIX_PATH_DELIMITER;
467
}
468
469
function normalizePathEntryForComparison(entry: string, platform: NodeJS.Platform): string {
469
- const normalized = stripWrappingQuotes(trimPathEntry(entry, platform));
470
+ const normalized = normalizePathEntry(entry, platform);
471
return platform === "win32" ? normalized.toLowerCase() : normalized;
472
}
473
@@ -675,7 +676,7 @@ const findOnPath = Effect.fnUntraced(function* (
676
const pathEntries: string[] = [];
677
const seenPathEntries = new Set<string>();
678
for (const entry of pathValue.split(pathDelimiterForPlatform(platform))) {
678
- const pathEntry = stripWrappingQuotes(trimPathEntry(entry, platform));
679
+ const pathEntry = normalizePathEntry(entry, platform);
680
if (pathEntry.length === 0 || seenPathEntries.has(pathEntry)) continue;
681
682
seenPathEntries.add(pathEntry);