MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / queryLoginShell

Function queryLoginShell

apps/desktop/src/main/login-shell-path.ts:48–73  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

46}
47
48async function queryLoginShell(command: string): Promise<string | null> {
49 // Try the user's own shell first, then the standard POSIX shells. On
50 // macOS/Linux those still pick up the login PATH from the system/user
51 // profile even when the user's interactive shell is something exotic (fish,
52 // nu) whose `command -v` syntax differs from POSIX.
53 const shells = Array.from(
54 new Set([process.env.SHELL, '/bin/zsh', '/bin/bash', '/bin/sh'].filter(Boolean))
55 ) as string[]
56
57 for (const shellPath of shells) {
58 try {
59 await fsp.access(shellPath, fsConstants.X_OK)
60 const { stdout } = await execFileAsync(shellPath, ['-lc', `command -v ${command}`], {
61 encoding: 'utf8',
62 timeout: LOGIN_SHELL_TIMEOUT_MS,
63 maxBuffer: 1024 * 1024,
64 windowsHide: true
65 })
66 const resolved = String(stdout).trim().split(/\r?\n/)[0]?.trim()
67 if (resolved && path.isAbsolute(resolved)) return resolved
68 } catch {
69 /* shell missing here, or command not found in it — try the next one */
70 }
71 }
72 return null
73}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected