Re: Add SHELL_EXIT_CODE to psql
От | Corey Huinker |
---|---|
Тема | Re: Add SHELL_EXIT_CODE to psql |
Дата | |
Msg-id | CADkLM=cnxKMVzajC6b1_a3P9wELF-Wtg8Qpi7uxv8kVdamShiA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Add SHELL_EXIT_CODE to psql (Corey Huinker <corey.huinker@gmail.com>) |
Ответы |
Re: Add SHELL_EXIT_CODE to psql
Re: Add SHELL_EXIT_CODE to psql |
Список | pgsql-hackers |
I've rebased and updated the patch to include documentation.
Regression tests have been moved to a separate patchfile because error messages will vary by OS and configuration, so we probably can't do a stable regression test, but having them handy at least demonstrates the feature.
Regression tests have been moved to a separate patchfile because error messages will vary by OS and configuration, so we probably can't do a stable regression test, but having them handy at least demonstrates the feature.
On Sun, Dec 4, 2022 at 12:35 AM Corey Huinker <corey.huinker@gmail.com> wrote:
Rebased. Still waiting on feedback before working on documentation.On Fri, Nov 4, 2022 at 5:23 AM Corey Huinker <corey.huinker@gmail.com> wrote:Oops, that sample output was from a previous run, should have been:-- SHELL_EXIT_CODE is undefined
\echo :SHELL_EXIT_CODE
:SHELL_EXIT_CODE
-- bad \!
\! borp
sh: line 1: borp: command not found
\echo :SHELL_EXIT_CODE
127
-- bad backtick
\set var `borp`
sh: line 1: borp: command not found
\echo :SHELL_EXIT_CODE
127
-- good \!
\! true
\echo :SHELL_EXIT_CODE
0
-- play with exit codes
\! exit 4
\echo :SHELL_EXIT_CODE
4
\set var `exit 3`
\echo :SHELL_EXIT_CODE
3On Fri, Nov 4, 2022 at 5:08 AM Corey Huinker <corey.huinker@gmail.com> wrote:Over in https://www.postgresql.org/message-id/eaf326ad693e74eba068f33a7f518039@oss.nttdata.com Justin Pryzby suggested that psql might need the ability to capture the shell exit code.This is a POC patch that does that, but doesn't touch on the ON_ERROR_STOP stuff.I've added some very rudimentary tests, but haven't touched the documentation, because I strongly suspect that someone will suggest a better name for the variable.But basically, it works like thisFeedback welcome.-- SHELL_EXIT_CODE is undefined\echo :SHELL_EXIT_CODE:SHELL_EXIT_CODE-- bad \!\! borpsh: line 1: borp: command not found\echo :SHELL_EXIT_CODE32512-- bad backtick\set var `borp`sh: line 1: borp: command not found\echo :SHELL_EXIT_CODE127-- good \!\! true\echo :SHELL_EXIT_CODE0-- play with exit codes\! exit 4\echo :SHELL_EXIT_CODE1024\set var `exit 3`\echo :SHELL_EXIT_CODE3
Вложения
В списке pgsql-hackers по дате отправления: