| 49 | } |
| 50 | |
| 51 | function isExecutable(shellPath: string): boolean { |
| 52 | try { |
| 53 | accessSync(shellPath, fsConstants.X_OK) |
| 54 | return true |
| 55 | } catch (_err) { |
| 56 | // Fallback for Nix and other environments where X_OK check might fail |
| 57 | try { |
| 58 | // Try to execute the shell with --version, which should exit quickly |
| 59 | // Use execFileSync to avoid shell injection vulnerabilities |
| 60 | execFileSync(shellPath, ['--version'], { |
| 61 | timeout: 1000, |
| 62 | stdio: 'ignore', |
| 63 | }) |
| 64 | return true |
| 65 | } catch { |
| 66 | return false |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Determines the best available shell to use. |