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:
parent
34cfa8601f
commit
7632b49d28
2 changed files with 5 additions and 1 deletions
|
|
@ -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 }",
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue