fix: normalize Windows cmd stdin newlines

This commit is contained in:
Codex
2026-06-06 02:25:28 +00:00
parent df8be84690
commit ec1ec6fc4b
+4
View File
@@ -1186,6 +1186,10 @@ function buildWindowsCmdStdinLauncherScript(cwd: string | null): string {
"$env:PYTHONUTF8 = '1';",
"$env:PYTHONIOENCODING = 'utf-8';",
"$script = [Console]::In.ReadToEnd();",
"$script = $script -replace \"`r`n\", \"`n\";",
"$script = $script -replace \"`r\", \"`n\";",
"$script = $script -replace \"`n\", \"`r`n\";",
"if (-not $script.EndsWith(\"`r`n\")) { $script += \"`r`n\" }",
"if ([string]::IsNullOrWhiteSpace($script)) { [Console]::Error.WriteLine('ssh win cmd requires a command line or stdin batch script'); exit 2 }",
`$prefix = ${powerShellSingleQuote(`${prefixLines.join("\r\n")}\r\n`)};`,
"$temp = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), ('unidesk-win-cmd-' + [guid]::NewGuid().ToString('N') + '.cmd'));",