MCPcopy Index your code
hub / github.com/anus-dev/ANUS / getShellConfiguration

Function getShellConfiguration

packages/core/src/utils/shell-utils.ts:39–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37 * @returns The ShellConfiguration for the current environment.
38 */
39export function getShellConfiguration(): ShellConfiguration {
40 if (isWindows()) {
41 const comSpec = process.env['ComSpec'] || 'cmd.exe';
42 const executable = comSpec.toLowerCase();
43
44 if (
45 executable.endsWith('powershell.exe') ||
46 executable.endsWith('pwsh.exe')
47 ) {
48 // For PowerShell, the arguments are different.
49 // -NoProfile: Speeds up startup.
50 // -Command: Executes the following command.
51 return {
52 executable: comSpec,
53 argsPrefix: ['-NoProfile', '-Command'],
54 shell: 'powershell',
55 };
56 }
57
58 // Default to cmd.exe for anything else on Windows.
59 // Flags for CMD:
60 // /d: Skip execution of AutoRun commands.
61 // /s: Modifies the treatment of the command string (important for quoting).
62 // /c: Carries out the command specified by the string and then terminates.
63 return {
64 executable: comSpec,
65 argsPrefix: ['/d', '/s', '/c'],
66 shell: 'cmd',
67 };
68 }
69
70 // Unix-like systems (Linux, macOS)
71 return { executable: 'bash', argsPrefix: ['-c'], shell: 'bash' };
72}
73
74/**
75 * Export the platform detection constant for use in process management (e.g., killing processes).

Callers 2

processMethod · 0.85

Calls 1

isWindowsFunction · 0.70

Tested by

no test coverage detected