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 22, 08:15 UTC
fix(shared): preserve escaped trailing whitespace in CLI arguments (#27485)
Co-authored-by: maria-rcks <maria@kuuro.net>
maco committed
Nov 1, 2026 at 03:39 UTC
6977721d00e1c29a1d87825f747dbb8ec6eb1f36
2 files changed
+19
-1
packages/shared/src/cliArgs.test.ts
+18
@@ -25,6 +25,24 @@ describe("tokenizeCliArgs", () => {
25
String.raw`--config model="gpt 5" --enable foo\ bar --config=profile='work profile'`,
26
),
27
).toEqual(["--config", "model=gpt 5", "--enable", "foo bar", "--config=profile=work profile"]);
28
+
29
+ for (const whitespace of [" ", "\t"]) {
30
+ const args = `--add-dir /tmp/project\\${whitespace}`;
31
+ expect(tokenizeCliArgs(args)).toEqual(["--add-dir", `/tmp/project${whitespace}`]);
32
+ expect(tokenizeCliArgs(`${args} --verbose`)).toEqual([
33
+ "--add-dir",
34
+ `/tmp/project${whitespace}`,
35
+ "--verbose",
36
+ ]);
37
+ }
38
+ });
39
+
40
+ it("ignores unescaped surrounding whitespace", () => {
41
+ expect(tokenizeCliArgs(" \t\n")).toEqual([]);
42
+ expect(tokenizeCliArgs(" \t--add-dir /tmp/project \t\n")).toEqual([
43
+ "--add-dir",
44
+ "/tmp/project",
45
+ ]);
46
});
47
48
it("preserves literal backslashes in path values", () => {
packages/shared/src/cliArgs.ts
+1
-1
@@ -8,7 +8,7 @@ export interface ParseCliArgsOptions {
8
}
9
10
export function tokenizeCliArgs(args?: string): ReadonlyArray<string> {
11
- const input = args?.trim();
11
+ const input = args;
12
if (!input) return [];
13
14
const tokens: string[] = [];