mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
* 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>
28 lines
895 B
TypeScript
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
|
|
}
|