(command: string)
| 46 | } |
| 47 | |
| 48 | async 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 | } |
no outgoing calls
no test coverage detected