@devries-cameron20 / t3code Mirror · read-only / commits / f6fd89b6f4
Fork 0

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, 12:15 UTC

fix(server): terminals start a $SHELL whose path contains a space (#30969)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

MarcoDotIO committed Nov 14, 2026 at 20:35 UTC f6fd89b6f49f0e59b245f12ad0789c08d96e10ec
2 files changed +31 -3
apps/server/src/terminal/Manager.test.ts
+26
@@ -1946,6 +1946,32 @@ it.layer(
1946 }),
1947 );
1948
1949 + it.effect("starts a $SHELL whose path contains a space", () =>
1950 + Effect.gen(function* () {
1951 + const { manager, ptyAdapter } = yield* createManager(5, {
1952 + env: { SHELL: "/Users/Jane Doe/.local/bin/fish" },
1953 + }).pipe(Effect.provide(layerWithHostPlatform("darwin")));
1954 +
1955 + yield* manager.open(openInput());
1956 +
1957 + expect(ptyAdapter.spawnInputs.map((input) => input.shell)).toEqual([
1958 + "/Users/Jane Doe/.local/bin/fish",
1959 + ]);
1960 + }),
1961 + );
1962 +
1963 + it.effect("starts a quoted $SHELL whose path contains a space and a dash", () =>
1964 + Effect.gen(function* () {
1965 + const { manager, ptyAdapter } = yield* createManager(5, {
1966 + env: { SHELL: '"/opt/my -shell/fish" -l' },
1967 + }).pipe(Effect.provide(layerWithHostPlatform("darwin")));
1968 +
1969 + yield* manager.open(openInput());
1970 +
1971 + expect(ptyAdapter.spawnInputs.map((input) => input.shell)).toEqual(["/opt/my -shell/fish"]);
1972 + }),
1973 + );
1974 +
1975 it.effect(
1976 "writes completion syntax for the fallback shell instead of the configured fish shell",
1977 () =>
apps/server/src/terminal/Manager.ts
+5 -3
@@ -539,9 +539,11 @@ function normalizeShellCommand(
539 return trimmed;
540 }
541
542 - const firstToken = trimmed.split(/\s+/g)[0]?.trim();
543 - if (!firstToken) return null;
544 - return firstToken.replace(/^['"]|['"]$/g, "");
542 + // A shell path can contain spaces, so only text from the first flag (`bash -l`) is dropped,
543 + // and a quoted path is kept whole even when it contains " -".
544 + const quoted = /^(['"])(.*?)\1(?:\s|$)/.exec(trimmed);
545 + const command = quoted ? quoted[2] : trimmed.split(/\s+(?=-)/)[0]?.replace(/^['"]|['"]$/g, "");
546 + return command || null;
547 }
548
549 function basenameForPlatform(command: string, platform: NodeJS.Platform): string {