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 --- doc/src/sgml/ref/psql-ref.sgml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7b8ae9fac30..29bbec21886 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -4267,6 +4267,34 @@ bar + + SHELL_ERROR + + + true if the last shell command + failed, false if it succeeded. + This applies to shell commands invoked via the \! + meta-command or backquote (`) expansion. + See also SHELL_EXIT_CODE. + + + + + + SHELL_EXIT_CODE + + + The exit status returned by the last shell command. + 0–127 represent program exit codes, 128–255 + indicate termination by a signal, and -1 indicates failure + to launch a program or to collect its exit status. + This applies to shell commands invoked via the \! + meta-command or backquote (`) expansion. + See also SHELL_ERROR. + + + + SHOW_ALL_RESULTS -- cgit v1.2.3