psql: set SHELL_ERROR and SHELL_EXIT_CODE in more places.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 6 Apr 2023 21:33:38 +0000 (17:33 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 6 Apr 2023 21:33:38 +0000 (17:33 -0400)
commit31ae2aa9d2c200a0d7d3283d749669a408ec7b65
treec8781c1909b5df38ed2c86bf334c1ae856f4a33c
parent029dea882a7aa34f46732473eed7c917505e6481
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
src/bin/psql/command.c
src/bin/psql/common.c
src/bin/psql/common.h
src/bin/psql/copy.c
src/bin/psql/psqlscanslash.l