fix(desktop): resolve login shell when loading env (#26449)

Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com>
This commit is contained in:
qunqin
2026-05-13 10:40:36 +08:00
committed by GitHub
co-authored by Brendan Allan
parent ff16eb8dea
commit 80543fb5dc
2 changed files with 19 additions and 2 deletions
+8 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test"
import { isNushell, mergeShellEnv, parseShellEnv } from "./shell-env"
import { isNushell, mergeShellEnv, parseShellEnv, resolveUserShell } from "./shell-env"
describe("shell env", () => {
test("parseShellEnv supports null-delimited pairs", () => {
@@ -34,6 +34,13 @@ describe("shell env", () => {
expect(env.OPENCODE_CLIENT).toBe("desktop")
})
test("resolveUserShell falls back to the login shell before /bin/sh", () => {
expect(resolveUserShell("/custom/env-shell", "/bin/zsh")).toBe("/custom/env-shell")
expect(resolveUserShell(undefined, "/bin/zsh")).toBe("/bin/zsh")
expect(resolveUserShell(undefined, "unknown")).toBe("/bin/sh")
expect(resolveUserShell(undefined, undefined)).toBe("/bin/sh")
})
test("isNushell handles path and binary name", () => {
expect(isNushell("nu")).toBe(true)
expect(isNushell("/opt/homebrew/bin/nu")).toBe(true)