pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars
5+ messages / 3 participants
[nested] [flat]

* BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars
@ 2014-07-23 17:56 fleminra@gmail.com
  2014-07-23 19:12 ` Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: fleminra@gmail.com @ 2014-07-23 17:56 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      11028
Logged by:          Robert Fleming
Email address:      fleminra@gmail.com
PostgreSQL version: 9.3.4
Operating system:   Ubuntu 14.04
Description:        

See http://stackoverflow.com/questions/19139330/

Basically, the colorized prompt suggested in
http://www.postgresql.org/docs/9.3/static/app-psql.html#APP-PSQL-PROMPTING
:

  testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# '

results in strange readline behavior. In that prompt, "%[" should be
preceded by "%001" and "%]" should be followed by "%002".

It seems to me that either psql should do this automatically, or
http://www.postgresql.org/docs/9.3/static/app-psql.html#APP-PSQL-PROMPTING
should be updated to use "%001" and "%002".

Thanks!


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars
  2014-07-23 17:56 BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars fleminra@gmail.com
@ 2014-07-23 19:12 ` Tom Lane <tgl@sss.pgh.pa.us>
  2014-07-23 21:34   ` Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars Robert Fleming <fleminra@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2014-07-23 19:12 UTC (permalink / raw)
  To: fleminra@gmail.com; +Cc: pgsql-bugs

fleminra@gmail.com writes:
> Basically, the colorized prompt suggested in
> http://www.postgresql.org/docs/9.3/static/app-psql.html#APP-PSQL-PROMPTING
> :

>   testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# '

> results in strange readline behavior. In that prompt, "%[" should be
> preceded by "%001" and "%]" should be followed by "%002".

Actually, %[ is supposed to expand to \001 and %] is supposed to expand
to \002.

The example seems to work as given for me.  Could you be more specific
about what's going wrong for you?  Also, are you sure you are really
using GNU readline, and not something else like libedit?

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars
  2014-07-23 17:56 BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars fleminra@gmail.com
  2014-07-23 19:12 ` Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars Tom Lane <tgl@sss.pgh.pa.us>
@ 2014-07-23 21:34   ` Robert Fleming <fleminra@gmail.com>
  2014-07-23 22:38     ` Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Robert Fleming @ 2014-07-23 21:34 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

Yes, sorry, actually it's using libedit. Is that supported?

Here is a video of what I'm seeing:
https://app.box.com/s/dj2hzo6tuny2os16t3rd
(This OGV file plays better in VLC than mplayer for me.)


On Wed, Jul 23, 2014 at 12:12 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> fleminra@gmail.com writes:
> > Basically, the colorized prompt suggested in
> >
> http://www.postgresql.org/docs/9.3/static/app-psql.html#APP-PSQL-PROMPTING
> > :
>
> >   testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# '
>
> > results in strange readline behavior. In that prompt, "%[" should be
> > preceded by "%001" and "%]" should be followed by "%002".
>
> Actually, %[ is supposed to expand to \001 and %] is supposed to expand
> to \002.
>
> The example seems to work as given for me.  Could you be more specific
> about what's going wrong for you?  Also, are you sure you are really
> using GNU readline, and not something else like libedit?
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars
  2014-07-23 17:56 BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars fleminra@gmail.com
  2014-07-23 19:12 ` Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars Tom Lane <tgl@sss.pgh.pa.us>
  2014-07-23 21:34   ` Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars Robert Fleming <fleminra@gmail.com>
@ 2014-07-23 22:38     ` Tom Lane <tgl@sss.pgh.pa.us>
  2014-08-01 19:55       ` Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars Robert Fleming <fleminra@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2014-07-23 22:38 UTC (permalink / raw)
  To: Robert Fleming <fleminra@gmail.com>; +Cc: pgsql-bugs

Robert Fleming <fleminra@gmail.com> writes:
> Yes, sorry, actually it's using libedit. Is that supported?

Ah.  We support libedit, but I'd not be a bit surprised if it does not
cope well with non-printing characters ...

A quick look into the readline.h supplied on my Mac OS X 10.9 machine
(which is from libedit not GNU readline) says that it defines
RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE, so at least in theory
you'd expect it to work.  A bit of experimentation says that it doesn't
work all that well though compared to my Linux box :-(.  Now, Apple has a
long track record of shipping broken versions of libedit, so this doesn't
prove a whole lot about what will happen on other platforms.

I'd make sure that PG was compiled against a version of readline.h that
provided definitions for RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE.
If it was, then whatever misbehavior you're seeing can be blamed on
libedit.  If you're using an old version of libedit it's possible that a
newer one would work better.  But really, libedit is full of inadequacies;
if you can possibly switch to GNU readline you'll probably be happier.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars
  2014-07-23 17:56 BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars fleminra@gmail.com
  2014-07-23 19:12 ` Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars Tom Lane <tgl@sss.pgh.pa.us>
  2014-07-23 21:34   ` Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars Robert Fleming <fleminra@gmail.com>
  2014-07-23 22:38     ` Re: BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars Tom Lane <tgl@sss.pgh.pa.us>
@ 2014-08-01 19:55       ` Robert Fleming <fleminra@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Robert Fleming @ 2014-08-01 19:55 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

I just switched/updated to the PostgreSQL packages from apt.postgresql.org
(instead of Ubuntu's own packages) and now all is working as advertised.

I had done some debugging in psql/prompt.c and indeed the
RL_PROMPT_START_IGNORE section was executing. So I never quite got to the
bottom of it, but am content to just to run with the updated packages.

Thanks for your help.
Robert

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2014-08-01 19:55 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-07-23 17:56 BUG #11028: psql doesn't use 0x01 and 0x02 to inform readline of non-printable PROMPT1 chars fleminra@gmail.com
2014-07-23 19:12 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-07-23 21:34   ` Robert Fleming <fleminra@gmail.com>
2014-07-23 22:38     ` Tom Lane <tgl@sss.pgh.pa.us>
2014-08-01 19:55       ` Robert Fleming <fleminra@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox