mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-21 18:26:09 +00:00
fix(core): preserve PowerShell exit codes
Capture native and PowerShell command status after the UTF-8 wrapper so failing commands still settle with a non-zero exit. Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
parent
34cfa8601f
commit
7632b49d28
@@ -181,6 +181,10 @@ export function args(file: string, command: string) {
|
||||
"[Console]::OutputEncoding = $utf8",
|
||||
"$OutputEncoding = $utf8",
|
||||
`& ([scriptblock]::Create([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${payload}'))))`,
|
||||
"$success = $?",
|
||||
"$code = $LASTEXITCODE",
|
||||
"if ($null -ne $code) { exit $code }",
|
||||
"if (-not $success) { exit 1 }",
|
||||
].join("; ")
|
||||
return [
|
||||
"-NoLogo",
|
||||
|
||||
@@ -69,7 +69,7 @@ describe("shell", () => {
|
||||
const args = ShellSelect.args("pwsh", 'Write-Output "你好"')
|
||||
expect(args.slice(0, 4)).toEqual(["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand"])
|
||||
expect(Buffer.from(args[4], "base64").toString("utf16le")).toBe(
|
||||
"$utf8 = [System.Text.UTF8Encoding]::new($false); [Console]::InputEncoding = $utf8; [Console]::OutputEncoding = $utf8; $OutputEncoding = $utf8; & ([scriptblock]::Create([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('V3JpdGUtT3V0cHV0ICLkvaDlpb0i'))))",
|
||||
"$utf8 = [System.Text.UTF8Encoding]::new($false); [Console]::InputEncoding = $utf8; [Console]::OutputEncoding = $utf8; $OutputEncoding = $utf8; & ([scriptblock]::Create([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('V3JpdGUtT3V0cHV0ICLkvaDlpb0i')))); $success = $?; $code = $LASTEXITCODE; if ($null -ne $code) { exit $code }; if (-not $success) { exit 1 }",
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user