diff --git a/src/test/shell.test.ts b/src/test/shell.test.ts index 51d0e85dc9..7e919f8a3b 100644 --- a/src/test/shell.test.ts +++ b/src/test/shell.test.ts @@ -78,6 +78,11 @@ describe("Shell Detection Tests", () => { expect(getShell()).to.equal("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe") }) + it("handles undefined shell profile gracefully", () => { + mockVsCodeConfig("windows", "NonExistentProfile", {}) + expect(getShell()).to.equal("C:\\Windows\\System32\\cmd.exe") + }) + it("uses WSL bash when profile indicates WSL source", () => { mockVsCodeConfig("windows", "WSL", { WSL: { source: "WSL" }, diff --git a/src/utils/shell.ts b/src/utils/shell.ts index 8871550a0e..2f7ffb3a88 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -105,7 +105,7 @@ function getWindowsShellFromVSCode(): string | null { } // If there's a specific path, return that immediately - if (profile.path) { + if (profile?.path) { return profile.path }