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