| 171 | } |
| 172 | |
| 173 | function resolveShellForLanguage(language: string): string { |
| 174 | const normalized = language.trim().toLowerCase() |
| 175 | |
| 176 | if (normalized === 'fish') { |
| 177 | const fish = whichSync('fish') |
| 178 | if (!fish) { |
| 179 | throw new Error('Found a fish code block, but fish is not installed.') |
| 180 | } |
| 181 | return fish |
| 182 | } |
| 183 | |
| 184 | if (normalized === 'zsh') { |
| 185 | const zsh = whichSync('zsh') |
| 186 | if (!zsh) { |
| 187 | throw new Error('Found a zsh code block, but zsh is not installed.') |
| 188 | } |
| 189 | return zsh |
| 190 | } |
| 191 | |
| 192 | return whichSync('bash') ?? whichSync('sh') ?? process.env.SHELL ?? '/bin/sh' |
| 193 | } |
| 194 | |
| 195 | function getShellArgs(shellPath: string, script: string): string[] { |
| 196 | const shellName = parse(shellPath).name.toLowerCase() |