From 31ae2aa9d2c200a0d7d3283d749669a408ec7b65 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 6 Apr 2023 17:33:38 -0400 Subject: psql: set SHELL_ERROR and SHELL_EXIT_CODE in more places. Make the \g, \o, \w, and \copy commands set these variables when closing a pipe. We missed doing this in commit b0d8f2d98, but it seems like a good idea. There are some remaining places in psql that intentionally don't update these variables after running a child program: * pager invocations * backtick evaluation within a prompt * \e (edit query buffer) Corey Huinker and Tom Lane Discussion: https://postgr.es/m/CADkLM=eSKwRGF-rnRqhtBORRtL49QsjcVUCa-kLxKTqxypsakw@mail.gmail.com --- doc/src/sgml/ref/psql-ref.sgml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 53875afbf02..f4f25d1b076 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -4277,8 +4277,12 @@ bar true if the last shell command failed, false if it succeeded. - This applies to shell commands invoked via the \! - meta-command or backquote (`) expansion. + This applies to shell commands invoked via the \!, + \g, \o, \w, + and \copy meta-commands, as well as backquote + (`) expansion. Note that + for \o, this variable is updated when the output + pipe is closed by the next \o command. See also SHELL_EXIT_CODE. @@ -4292,8 +4296,12 @@ bar 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. + This applies to shell commands invoked via the \!, + \g, \o, \w, + and \copy meta-commands, as well as backquote + (`) expansion. Note that + for \o, this variable is updated when the output + pipe is closed by the next \o command. See also SHELL_ERROR. -- cgit v1.2.3