import { quotePosixShellUnlessPlain } from './shell-argument-quoting' // Why: escape rules are a property of the *target* shell receiving the path, // not the client OS. A Windows client dropping onto a Linux SSH worktree must // produce POSIX-quoted output; passing a userAgent string here coupled escape // rules to the client and silently misquoted cross-platform SSH drops. export function shellEscapePath(path: string, targetShell: 'posix' | 'windows'): string { if (targetShell === 'windows') { return /^[a-zA-Z0-9_./@:\\-]+$/.test(path) ? path : `"${path}"` } return quotePosixShellUnlessPlain(path) }