Skip to content

Commit f92daf1

Browse files
fixfonmaria-rcks
andauthored
fix(server): macOS Bash terminals now start as login shells (pingdotgg#22295)
Co-authored-by: maria-rcks <[email protected]>
1 parent bc92973 commit f92daf1

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎apps/server/src/terminal/Manager.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,25 @@ it.layer(
20642064
}),
20652065
);
20662066

2067+
it.effect("starts bash as a login shell on macOS only", () =>
2068+
Effect.gen(function* () {
2069+
for (const [platform, shell, args] of [
2070+
["darwin", "/bin/bash", ["-l"]],
2071+
["darwin", "/opt/homebrew/bin/bash", ["-l"]],
2072+
["linux", "/bin/bash", undefined],
2073+
["win32", "C:\\Program Files\\Git\\bin\\bash.exe", undefined],
2074+
["darwin", "/bin/zsh", ["-o", "nopromptsp"]],
2075+
["linux", "/bin/zsh", ["-o", "nopromptsp"]],
2076+
["win32", "pwsh.exe", ["-NoLogo"]],
2077+
] as const) {
2078+
const { manager, ptyAdapter } = yield* createManager(5, {
2079+
shellResolver: () => shell,
2080+
}).pipe(Effect.provide(layerWithHostPlatform(platform)));
2081+
yield* manager.open(openInput());
2082+
expect.soft(ptyAdapter.spawnInputs[0]?.args, `${platform} ${shell}`).toEqual(args);
2083+
}
2084+
}),
2085+
);
20672086
it.effect("removes terminal metadata subscriptions when initial delivery fails", () =>
20682087
Effect.gen(function* () {
20692088
const { manager } = yield* createManager();

‎apps/server/src/terminal/Manager.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,10 @@ function shellCandidateFromCommand(
566566
if (platform !== "win32" && shellName === "zsh") {
567567
return { shell: command, args: ["-o", "nopromptsp"] };
568568
}
569+
// Login shells load ~/.bash_profile, matching macOS terminal startup.
570+
if (platform === "darwin" && shellName === "bash") {
571+
return { shell: command, args: ["-l"] };
572+
}
569573
return { shell: command };
570574
}
571575

0 commit comments

Comments
 (0)