MCPcopy Index your code
hub / github.com/coder/mux / getWindowsFallbackCommand

Function getWindowsFallbackCommand

src/node/utils/main/resolveLocalPtyShell.ts:81–97  ·  view source on GitHub ↗

Resolve the Windows fallback shell command: prefer COMSPEC when valid, otherwise cmd.exe.

(
  env: NodeJS.ProcessEnv,
  isPathAccessible: (candidatePath: string) => boolean
)

Source from the content-addressed store, hash-verified

79
80/** Resolve the Windows fallback shell command: prefer COMSPEC when valid, otherwise cmd.exe. */
81function getWindowsFallbackCommand(
82 env: NodeJS.ProcessEnv,
83 isPathAccessible: (candidatePath: string) => boolean
84): string {
85 const comspec = env.COMSPEC?.trim();
86 if (!comspec) {
87 return "cmd.exe";
88 }
89
90 // If COMSPEC is a path-like value that doesn't validate, fall back to bare cmd.exe
91 // so the OS can resolve it via PATH.
92 if (isPathLikeShell(comspec) && !isPathAccessible(comspec)) {
93 return "cmd.exe";
94 }
95
96 return comspec;
97}
98
99function isCandidateAvailable(
100 command: string,

Callers 1

resolveLocalPtyShellFunction · 0.85

Calls 1

isPathLikeShellFunction · 0.85

Tested by

no test coverage detected