MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / detectViaParentProcessInspection

Function detectViaParentProcessInspection

cli/src/utils/detect-shell.ts:60–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58}
59
60function detectViaParentProcessInspection(): ShellName | null {
61 try {
62 if (process.platform === 'win32') {
63 const parentProcess = execSync(
64 'wmic process get ParentProcessId,CommandLine',
65 { stdio: 'pipe' },
66 )
67 .toString()
68 .toLowerCase()
69
70 if (parentProcess.includes('powershell')) return 'powershell'
71 if (parentProcess.includes('cmd.exe')) return 'cmd.exe'
72 } else {
73 const parentProcess = execSync(`ps -p ${process.ppid} -o comm=`, {
74 stdio: 'pipe',
75 })
76 .toString()
77 .trim()
78 const normalized = normalizeCandidate(parentProcess)
79 if (normalized) return normalized
80 }
81 } catch {
82 // Ignore inspection errors
83 }
84
85 return null
86}
87
88function normalizeCandidate(value?: string | null): ShellName | null {
89 if (!value) {

Callers 1

detectShellFunction · 0.85

Calls 1

normalizeCandidateFunction · 0.85

Tested by

no test coverage detected