Re: Add SHELL_EXIT_CODE to psql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, Maxim Orlov <orlovmg(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add SHELL_EXIT_CODE to psql
Date: 2023-04-06 21:41:29
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Corey Huinker <corey(dot)huinker(at)gmail(dot)com> writes:
> This is a follow up patch to apply the committed pattern to the various
> piped output commands.

Pushed with some changes:

* You didn't update the documentation.

* I thought this was way too many copies of the same logic. I made a
subroutine to set these variables, and changed the original uses too.

* You didn't change \w (exec_command_write) to set these variables.
I'm assuming that was an oversight; if it was intentional, please
explain why.

I looked through psql's other uses of pclose() and system(),
and found:
* pager invocations
* backtick evaluation within a prompt
* \e (edit query buffer)
I think that not changing these variables in those places is a good
idea. For instance, if prompt display could change them then they'd
never survive long enough to be useful; plus, having the behavior
vary depending on your prompt settings seems pretty horrid.
In general, these things are mainly useful to scripts, and I doubt
that we want their interactive behavior to vary from scripted behavior,
so setting them during interactive-only operations seems bad.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2023-04-06 21:44:31 Re: Option to not use ringbuffer in VACUUM, using it in failsafe mode
Previous Message Jonathan S. Katz 2023-04-06 21:37:39 Re: PostgreSQL 16 Release Management Team & Feature Freeze