From: | Geoff Winkless <pgsqladmin(at)geoff(dot)dj> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Geoff Winkless <pgsqladmin(at)geoff(dot)dj>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Robert Haas <robertmhaas(at)gmail(dot)com>, Everaldo Canuto <everaldo(dot)canuto(at)gmail(dot)com>, Chapman Flack <chap(at)anastigmatix(dot)net>, Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal: alternative psql commands quit and exit |
Date: | 2018-01-16 11:44:37 |
Message-ID: | CAEzk6feRR-XNr-Lzv5f5LADjmexSFSfVau77UqqFXEnMhSus2A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 15 January 2018 at 17:53, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Geoff Winkless <pgsqladmin(at)geoff(dot)dj> writes:
>> At this point it depends quite how far down the rabbit-hole you want
>> to go to stop people googling "how do I exit psql", I suppose :p
>
> Well, I concur with Robert's comment upthread that we don't want to
> print any advice that's possibly wrong. So I'd rather provide hints
> that are sure to work, rather than hints that might represent the
> way to get out with fewest keystrokes, but could go wrong in unusual
> situations.
A quick PoC.
I should say upfront that I've no axe to grind over this, if no-one
likes the idea I don't mind: I'm not sure I like it myself (it's quite
an aggressive stance to take, I think) - I just wanted to see if it
would work, and provide it as a working possibility.
Basically, I intercept every keypress before we send it to readline.
If it's 4 (Ctrl-D) we replace the buffer with \q<lf> which then quits,
even if there's something in the buffer. So simply sending "Ctrl-D to
quit" would always be true. Everything else just gets passed through
to readline directly.
Would need additional work to make the same thing work when readline
is disabled. I decided it wouldn't be worth the effort if the basic
idea of always intercepting Ctrl-D doesn't gain traction.
It's patched against 9.5.1, purely because that's the version I
already had source built for on my devbox. Again, if the idea is one
that people like I'm happy to rebase it against head.
I've also no idea whether Ctrl-D would be 4 in other locales.
I also don't know how much of the boilerplate code from the readline
docs is required, eg the sigwinch stuff.
Geoff
Attachment | Content-Type | Size |
---|---|---|
input.c.patch | application/octet-stream | 2.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Kyotaro HORIGUCHI | 2018-01-16 12:23:01 | Re: [HACKERS] [PATCH] Improve geometric types |
Previous Message | Amit Khandekar | 2018-01-16 10:42:48 | Re: [HACKERS] UPDATE of partition key |