On 15 January 2018 at 17:53, Tom Lane <[email protected]> wrote: > Geoff Winkless <[email protected]> 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
input.c.patch
Description: Binary data
