Files
orca/src/main/ssh/ssh-login-shell-command.ts
T
Haohan Lin 190ed7d4ed fix(ssh): make POSIX relay wrapper survive csh/tcsh login shells (#8709)
Reconstruct remote POSIX commands with bounded printf arguments so non-POSIX SSH login shells can forward them without requiring remote base64. Preserve relay and system-SSH stdin, and centralize login-shell flag selection for csh/tcsh compatibility.\n\nValidated against real csh and tcsh OpenSSH targets with built-in and system SSH, including cold relay deployment, stdin upload, PTY I/O, file mutation, and reconnect.
2026-07-15 02:38:40 -07:00

12 lines
565 B
TypeScript

import { shellEscape } from './ssh-connection-utils'
const COMMAND_ONLY_SHELLS = new Set(['sh', 'dash', 'csh', 'tcsh'])
/** Build a command using the startup mode supported by the configured login shell. */
export function buildSshLoginShellCommand(shell: string, command: string): string {
const shellName = shell.split('/').at(-1)
// Why: csh/tcsh reject combined -lc, while sh/dash do not need login mode here.
const mode = shellName && COMMAND_ONLY_SHELLS.has(shellName) ? '-c' : '-lc'
return `${shellEscape(shell)} ${mode} ${shellEscape(command)}`
}