MCPcopy Index your code
hub / github.com/anomalyco/opencode / loadShellEnv

Function loadShellEnv

packages/desktop/src/main/shell-env.ts:70–94  ·  view source on GitHub ↗
(shell: string, logger: ShellEnvLogger)

Source from the content-addressed store, hash-verified

68}
69
70export 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
96export function mergeShellEnv(shell: Record<string, string> | null, env: Record<string, string>) {
97 return {

Callers 1

preferAppEnvFunction · 0.90

Calls 3

isNushellFunction · 0.85
probeFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected