(shell: string, logger: ShellEnvLogger)
| 68 | } |
| 69 | |
| 70 | export function loadShellEnv(shell: string, logger: ShellEnvLogger) { |
| 71 | if (isNushell(shell)) { |
| 72 | logger.log(`[server] Skipping shell env probe for nushell: ${shell}`) |
| 73 | return null |
| 74 | } |
| 75 | |
| 76 | const interactive = probe(shell, "-il") |
| 77 | if (interactive.type === "Loaded") { |
| 78 | logger.log(`[server] Loaded shell environment with -il (${Object.keys(interactive.value).length} vars)`) |
| 79 | return interactive.value |
| 80 | } |
| 81 | if (interactive.type === "Timeout") { |
| 82 | logger.log(`[server] Interactive shell env probe timed out: ${shell}`) |
| 83 | return null |
| 84 | } |
| 85 | |
| 86 | const login = probe(shell, "-l") |
| 87 | if (login.type === "Loaded") { |
| 88 | logger.log(`[server] Loaded shell environment with -l (${Object.keys(login.value).length} vars)`) |
| 89 | return login.value |
| 90 | } |
| 91 | |
| 92 | logger.log(`[server] Falling back to app environment: ${shell}`) |
| 93 | return null |
| 94 | } |
| 95 | |
| 96 | export function mergeShellEnv(shell: Record<string, string> | null, env: Record<string, string>) { |
| 97 | return { |
no test coverage detected