






















@@ -46,38 +46,59 @@ describe("getShellConfig", () => {
46464747if (isWin) {
4848it("uses PowerShell on Windows", () => {
49-const { shell } = getShellConfig();
49+const { shell, args } = getShellConfig();
5050const normalized = shell.toLowerCase();
5151expect(normalized.includes("powershell") || normalized.includes("pwsh")).toBe(true);
52+expect(args).toEqual(["-NoProfile", "-NonInteractive", "-Command"]);
5253});
5354return;
5455}
55565657it("prefers bash when fish is default and bash is on PATH", () => {
5758const binDir = createTempCommandDir(tempDirs, [{ name: "bash" }]);
5859process.env.PATH = binDir;
59-const { shell } = getShellConfig();
60+const { shell, args } = getShellConfig();
6061expect(shell).toBe(path.join(binDir, "bash"));
62+expect(args).toEqual(["--noprofile", "--norc", "-c"]);
6163});
62646365it("falls back to sh when fish is default and bash is missing", () => {
6466const binDir = createTempCommandDir(tempDirs, [{ name: "sh" }]);
6567process.env.PATH = binDir;
66-const { shell } = getShellConfig();
68+const { shell, args } = getShellConfig();
6769expect(shell).toBe(path.join(binDir, "sh"));
70+expect(args).toEqual(["-c"]);
6871});
69727073it("falls back to env shell when fish is default and no sh is available", () => {
7174process.env.PATH = "";
72-const { shell } = getShellConfig();
75+const { shell, args } = getShellConfig();
7376expect(shell).toBe("/usr/bin/fish");
77+expect(args).toEqual(["--no-config", "-c"]);
78+});
79+80+it("uses startup-suppressed args for zsh env shells", () => {
81+process.env.SHELL = "/bin/zsh";
82+process.env.PATH = "";
83+const { shell, args } = getShellConfig();
84+expect(shell).toBe("/bin/zsh");
85+expect(args).toEqual(["-f", "-c"]);
86+});
87+88+it("uses startup-suppressed args for bash env shells", () => {
89+process.env.SHELL = "/bin/bash";
90+process.env.PATH = "";
91+const { shell, args } = getShellConfig();
92+expect(shell).toBe("/bin/bash");
93+expect(args).toEqual(["--noprofile", "--norc", "-c"]);
7494});
75957696it("uses sh when SHELL is unset", () => {
7797delete process.env.SHELL;
7898process.env.PATH = "";
79-const { shell } = getShellConfig();
99+const { shell, args } = getShellConfig();
80100expect(shell).toBe("sh");
101+expect(args).toEqual(["-c"]);
81102});
8210383104it("falls back to sh on PATH when SHELL is /usr/bin/false", () => {
@@ -93,15 +114,26 @@ describe("getShellConfig", () => {
93114const binDir = createTempCommandDir(tempDirs, [{ name: "sh" }]);
94115process.env.SHELL = "/sbin/nologin";
95116process.env.PATH = binDir;
96-const { shell } = getShellConfig();
117+const { shell, args } = getShellConfig();
97118expect(shell).toBe(path.join(binDir, "sh"));
119+expect(args).toEqual(["-c"]);
120+});
121+122+it("falls back to startup-suppressed bash on PATH when SHELL is a placeholder", () => {
123+const binDir = createTempCommandDir(tempDirs, [{ name: "bash" }]);
124+process.env.SHELL = "/usr/bin/false";
125+process.env.PATH = binDir;
126+const { shell, args } = getShellConfig();
127+expect(shell).toBe(path.join(binDir, "bash"));
128+expect(args).toEqual(["--noprofile", "--norc", "-c"]);
98129});
99130100131it("falls back to bare sh when SHELL is a placeholder and no sh is on PATH", () => {
101132process.env.SHELL = "/usr/bin/false";
102133process.env.PATH = "";
103-const { shell } = getShellConfig();
134+const { shell, args } = getShellConfig();
104135expect(shell).toBe("sh");
136+expect(args).toEqual(["-c"]);
105137});
106138});
107139此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。