How to *really* quit psql?

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: How to *really* quit psql?
Date: 2022-11-19 18:55:36
Message-ID: a7acfaf-331d-965e-3b44-7c51b22c3727@minesparis.psl.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello devs,

I want to abort a psql script. How can I do that? The answer seems to be
\quit, but it is not so simple:

- when the current script is from a terminal, you exit psql, OK

- when the current script is from a file (-f, <), you exit psql, OK

- when the current script is included from something,
you quit the current script and proceed after the \i of next -f, BAD

Question: is there any way to really abort a psql script from an included
file?

I've found "\! kill $PPID" which works with bash, but I'm not sure of the
portability and I was hoping for something straightforward and cleaner.

If there is really no simple way, would it be okay to add a \exit which
does that?

--
Fabien.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-11-19 19:10:31 Re: How to *really* quit psql?
Previous Message Nathan Bossart 2022-11-19 18:50:04 Re: predefined role(s) for VACUUM and ANALYZE