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
commit 80543fb5dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import { spawnSync } from "node:child_process"
import { userInfo } from "node:os"
import { basename } from "node:path"
import { getLogger } from "./logging"
@ -6,8 +7,17 @@ const TIMEOUT = 5_000
type Probe = { type: "Loaded"; value: Record<string, string> } | { type: "Timeout" } | { type: "Unavailable" }
export function resolveUserShell(envShell: string | undefined, loginShell: string | null | undefined) {
const resolvedLoginShell = loginShell && loginShell !== "unknown" ? loginShell : undefined
return envShell || resolvedLoginShell || "/bin/sh"
}
export function getUserShell() {
return process.env.SHELL || "/bin/sh"
try {
return resolveUserShell(process.env.SHELL, userInfo().shell)
} catch {
return resolveUserShell(process.env.SHELL, undefined)
}
}
export function parseShellEnv(out: Buffer) {