model-writtenrun 4476 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Corey Huinker proposed exposing the last shell command's exit status as SHELL_EXIT_CODE for shell escapes and backtick expansion, crediting an earlier suggestion from Justin Pryzby and explicitly leaving ON_ERROR_STOP changes outside this patch #1.
- After an initial rebase, Corey added documentation and separated the regression tests because shell diagnostics vary across platforms; Maxim Orlov then confirmed the feature worked, reported macOS test failures, and suggested suppressing shell diagnostics #4 #5.
- Corey considered automatic stderr suppression and additional psql variables, while Isaac Morland suggested redirecting stderr before invoking the shell; Corey ultimately chose a regression-only PG_OS_TARGET environment variable and added SHELL_ERROR alongside the numeric status #7 #8 #11.
- Maxim's review prompted formatting cleanup and removal of leftover commented code, while Corey retained the dedicated PG_OS_TARGET variable to match build-time platform selection; a subsequent documentation rebase added anchors for both variables #12 #13 #17.
- After portability failures involving wait-status macros, Corey moved status decoding into the shared wait_result_to_exit_code() helper and expanded the submission to three patches #18 #19.
- Robert Haas questioned the need for SHELL_ERROR, then accepted Corey's explanation that a ready-made boolean supports psql conditionals without expression evaluation; Corey also relaxed regression checks to accommodate shell-dependent exit codes #21 #22 #23 #25.
- Maxim later considered the series ready apart from formatting, which Corey addressed, while Thomas Munro confirmed that the reported FreeBSD postgres_fdw failure came from an unrelated flaky test #28 #29 #30.
- Tom Lane challenged ambiguous signal and ferror reporting and considered the regression tests too weak and potentially unsafe to commit; Corey explained the scripting use cases for retaining numeric exit status and accepted that the tests could be omitted #32 #33.
- Justin Pryzby proposed separating failure categories and prioritizing pclose errors, and Tom settled on shell-style 128+N signal encoding with -1 for internal failures; Corey implemented signal encoding and pclose precedence, manually tested signal termination, and replaced the test commands with non-executable platform targets #34 #35 #36.
- Maxim endorsed the revised patch, but Tom identified remaining misuse of ferror's return value and a misleading success fallback in the helper, which Corey changed to -1 #37 #38 #39.
- Tom committed the feature and helper from #39 as b0d8f2d983, leaving out the regression tests and their PG_OS_TARGET prerequisite, explicitly passing through -1, and preserving historical backtick substitution behavior on ordinary nonzero exits #40.
- Corey then submitted a separate patch to update the variables when piped output and copy commands close their child processes, identifying this as an omission from the newly committed feature #42.
- Tom committed that follow-up as 31ae2aa9d2, adding documentation and the missing write-command case while consolidating all callers through SetShellResultVariables() #45.
- By the final message, both feature stages had landed; pager invocations, prompt backticks, and editor commands intentionally remained excluded so interactive operations would not overwrite status values needed by scripts #45.