Summary
execSync / execFileSync do not throw on a non-zero exit. Node throws an Error (with the command output attached) when the child exits non-zero:
try { cp.execSync("exit 4"); } catch (e) {
// Object.keys(e) → status, signal, output, pid, stdout, stderr
// e.status === 4
}
Today (perry 0.5.1029) js_child_process_exec_sync returns the stdout string regardless of exit code, and js_child_process_exec_file_sync likewise never throws.
What to do
- On non-zero exit, throw an
Error carrying status (exit code), signal, pid, output ([null, stdout, stderr]), stdout, stderr, and cmd.
- The zero-exit path keeps returning stdout (Buffer by default, string with an
encoding option).
Compat note: this changes today's lenient behavior (always returns stdout), so existing Perry programs that call execSync on commands that can fail without try/catch will start throwing — matching Node, but worth flagging at merge. Pairs with the exec error-shape and encoding issues.
Parent: #1780. perry 0.5.1029.
Summary
execSync/execFileSyncdo not throw on a non-zero exit. Node throws anError(with the command output attached) when the child exits non-zero:Today (perry 0.5.1029)
js_child_process_exec_syncreturns the stdout string regardless of exit code, andjs_child_process_exec_file_synclikewise never throws.What to do
Errorcarryingstatus(exit code),signal,pid,output([null, stdout, stderr]),stdout,stderr, andcmd.encodingoption).Compat note: this changes today's lenient behavior (always returns stdout), so existing Perry programs that call
execSyncon commands that can fail without try/catch will start throwing — matching Node, but worth flagging at merge. Pairs with the exec error-shape and encoding issues.Parent: #1780. perry 0.5.1029.