From b0d8f2d983cb25d1035fae1cd7de214dd67809b4 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 21 Mar 2023 13:03:42 -0400 Subject: Add SHELL_ERROR and SHELL_EXIT_CODE magic variables to psql. These are set after a \! command or a backtick substitution. SHELL_ERROR is just "true" for error (nonzero exit status) or "false" for success, while SHELL_EXIT_CODE records the actual exit status following standard shell/system(3) conventions. Corey Huinker, reviewed by Maxim Orlov and myself Discussion: https://postgr.es/m/CADkLM=cWao2x2f+UDw15W1JkVFr_bsxfstw=NGea7r9m4j-7rQ@mail.gmail.com --- src/bin/psql/help.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/bin/psql/help.c') diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index e45c4aaca5a..48fd51592aa 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -451,6 +451,10 @@ helpVariables(unsigned short int pager) HELP0(" SERVER_VERSION_NAME\n" " SERVER_VERSION_NUM\n" " server's version (in short string or numeric format)\n"); + HELP0(" SHELL_ERROR\n" + " true if the last shell command failed, false if it succeeded\n"); + HELP0(" SHELL_EXIT_CODE\n" + " exit status of the last shell command\n"); HELP0(" SHOW_ALL_RESULTS\n" " show all results of a combined query (\\;) instead of only the last\n"); HELP0(" SHOW_CONTEXT\n" -- cgit v1.2.3