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