MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / getScriptShell

Function getScriptShell

projects/electron/src/modules/code/process.ts:114–148  ·  view source on GitHub ↗

* Get the shell to use for script execution. * On Windows, tries to find Git Bash first, then falls back to PowerShell. * On Unix, uses SHELL env var or defaults to /bin/bash.

()

Source from the content-addressed store, hash-verified

112 * On Unix, uses SHELL env var or defaults to /bin/bash.
113 */
114function getScriptShell(): { shell: string; args: (scriptPath: string) => string[]; extension: string; usePreamble: boolean } {
115 if (process.platform === "win32") {
116 // Try Git Bash first (best compatibility with bash scripts)
117 const gitBashPaths = [
118 "C:\\Program Files\\Git\\bin\\bash.exe",
119 "C:\\Program Files (x86)\\Git\\bin\\bash.exe",
120 ]
121 for (const bashPath of gitBashPaths) {
122 if (fs.existsSync(bashPath)) {
123 return {
124 shell: bashPath,
125 args: (scriptPath) => [scriptPath],
126 extension: ".sh",
127 usePreamble: true,
128 }
129 }
130 }
131 // Fall back to PowerShell (scripts may need adaptation)
132 logger.warn("[Process] Git Bash not found, falling back to PowerShell. Bash scripts may not work correctly.")
133 return {
134 shell: "powershell.exe",
135 args: (scriptPath) => ["-ExecutionPolicy", "Bypass", "-File", scriptPath],
136 extension: ".ps1",
137 usePreamble: false,
138 }
139 }
140 // Unix: use SHELL env or default to /bin/bash
141 const shell = process.env.SHELL || "/bin/bash"
142 return {
143 shell,
144 args: (scriptPath) => [scriptPath],
145 extension: ".sh",
146 usePreamble: true,
147 }
148}
149
150// ============================================================================
151// State

Callers 1

handleStartScriptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected