Files
orca/src/shared/openssh-default-shell.ts
T
OrcaWinandm4air b4d5b7de7a fix(terminal): honor the OpenSSH DefaultShell on Windows SSH hosts running orcad (#27085)
* fix(terminal): honor the OpenSSH DefaultShell on Windows SSH hosts running orcad (#9327)

* fix(terminal): honor only a PowerShell-family DefaultShell so agent launch quoting still matches

* fix(terminal): import the registry reader's runner from @orca/process-host

* test(terminal): type the spawnSync stub's options

---------

Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local>
2026-10-09 19:53:58 -07:00

28 lines
895 B
TypeScript

import { runProcessSync } from '@orca/process-host'
import { windowsSystem32Binary } from '@orca/process-host/windows-system-binary'
const OPENSSH_REGISTRY_KEY = 'HKLM\\SOFTWARE\\OpenSSH'
let openSshDefaultShell: string | undefined
/** The Windows OpenSSH server's `DefaultShell` login shell, or '' when unset or unreadable. Memoized. */
export function readOpenSshDefaultShell(): string {
if (openSshDefaultShell !== undefined) {
return openSshDefaultShell
}
try {
const result = runProcessSync({
program: windowsSystem32Binary('reg.exe'),
args: ['query', OPENSSH_REGISTRY_KEY, '/v', 'DefaultShell'],
timeoutMs: 3000
})
const match =
result.code === 0 ? result.stdout.match(/^\s*DefaultShell\s+REG_\w+\s+(.+?)\s*$/im) : null
openSshDefaultShell = match?.[1] ?? ''
} catch {
openSshDefaultShell = ''
}
return openSshDefaultShell
}