Re: psql prompts with invisible characters

From: Reece Hart <reece(at)in-machina(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: psql prompts with invisible characters
Date: 2004-01-19 17:56:20
Message-ID: 1074534980.5061.102.camel@tallac
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

On Fri, 2004-01-16 at 13:34, Tom Lane wrote:

> how far back do they have support
> for these RL_PROMPT_foo symbols, and do we need to consider the
> possibility that the symbols aren't there or act differently?

Short answer: I believe that any readline newer than Feb 1999 oughta
work.

The RL_PROMPT_* markers are undocumented features of readline. The patch
I sent works fine with RL 4.2 and 4.3 on linux-x86. From the readline
changelogs, I deduced that these were added with 4.0 (ca. Feb 1999). I
recall that there have been fixes to the prompt display code over the
years, but I believe these were not related to invisible char handling.

> lack of readline does not imply that the prompt is
> being printed on a dumb terminal.

Obviously. Indeed that would be foolish logic. You and I are reading
this differently and expounding on the several cases I was considering
is immaterial since I wasn't advocating for stripping (i.e., protecting
the user from himself) anyway. Let's chop the #else clause and leave it
at that. I, too, am inclined to let the user shoot himself in the foot
and get a garbled prompt if he uses a fancy prompt on an un-fancy term.

I see only three downsides to this patch:
1) In the case of someone who has %[ or %] in their prompt (I haven't a
clue why they would) and expected [ or ] to get displayed, this patch
will appear to be a behavior change.
2) Some users will undoubtedly be confused when they try a fancy prompt
in a dumb term and see a prompt like
^[[1;33;40mrkh(at)csb=^[[0m>
(e.g., bring up psql in an emacs shell)
3) All features will generate pgsql- list traffic. This will be no
different.
4) It relies on an undocumented feature in readline. Because bash uses
this feature too and because they're both products of Chet Ramey, it's
hard to see why this support would disappear (not impossible, mind you).

What else do you need to get this submitted? If it eases your mind, I'll
wrap it in a --enable-prompt-invisibles configure flag so that it would
be an experimental feature for the moment. I can only test this on
linux-x86 and osf1-alpha... and I certainly have no idea what the
windows or mac folks do (do they use configure at all?).

BTW, is there a coding style guide or pgsql-patch guide somewhere? For
example, are patches acceptable as attachments (as opposed to inline)?
Peter recently admonished someone for // comments, "personal" comments,
and archive references... this is also good fodder for a style guide.
And, is it preferred to diff against cvs instead? If so, which branch?

-Reece

--
Reece Hart, http://www.in-machina.com/~reece/, GPG:0x25EC91A0 0xD178AAF9

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-01-19 19:15:08 Patch for search_path --- apply to 7.4 branch?
Previous Message Andrew Dunstan 2004-01-19 14:09:45 Re: [patch] 7.4 initdb - drop trailing slash from $PGDATA