dbTalk Databases Forums  

[BUGS] Small bug fix in readline promt handling

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] Small bug fix in readline promt handling in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Martin Pitt
 
Posts: n/a

Default [BUGS] Small bug fix in readline promt handling - 12-22-2005 , 12:24 PM







--oPmsXEqKQNHCSXW7
Content-Type: multipart/mixed; boundary="EXKGNeO8l0xGFBjy"
Content-Disposition: inline


--EXKGNeO8l0xGFBjy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi!

When using %[ and %] (prompt length ignore area) in .psqlrc's prompt
formats, psql sends a \001 before the actual readline commands
(RL_PROMPT_{START,END}_IGNORE). This is the way bash handles the
shell's PSx format, but it is not a readline command, but a bash
specific quirk.

Example .psqlrc:
\set PROMPT1 '%[%033[0;35m%]%/@%m%R%#%[%033[0;22m%] '

-> not correctly handled, the cursor will be in the middle of the
prompt.

Attached patch fixes this. This was investigated and patched by Aaron
Schrab <aaron (AT) schrab (DOT) com>, full details at http://bugs.debian.org/343616

Thank you for considering this, and have a merry christmas!

Martin

--=20
Martin Pitt http://www.piware.de
Ubuntu Developer http://www.ubuntu.com
Debian Developer http://www.debian.org

In a world without walls and fences, who needs Windows and Gates?

--EXKGNeO8l0xGFBjy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="12-readline-prompt-ignore.patch"
Content-Transfer-Encoding: quoted-printable

diff -ruN postgresql-8.1.1-old/src/bin/psql/prompt.c postgresql-8.1.1/src/b=
in/psql/prompt.c
--- postgresql-8.1.1-old/src/bin/psql/prompt.c 2005-10-15 04:49:40.00000000=
0 +0200
+++ postgresql-8.1.1/src/bin/psql/prompt.c 2005-12-22 19:12:47.000000000 +0=
100
@@ -296,8 +296,7 @@
* characters in prompt strings must be marked as such, in
* order to properly display the line during editing.
*/
- buf[0] =3D '\001';
- buf[1] =3D (*p =3D=3D '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_I=
GNORE;
+ buf[0] =3D (*p =3D=3D '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_I=
GNORE;
#endif /* USE_READLINE */
break;
=20

--EXKGNeO8l0xGFBjy--

--oPmsXEqKQNHCSXW7
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDqu9HDecnbV4Fd/IRAsJ9AJ9paQ2QA28gYJ2n302vQGDB8MvewACg4VAG
z6WAEAb9x7QMzMlDwEwSnk4=
=gaq4
-----END PGP SIGNATURE-----

--oPmsXEqKQNHCSXW7--

Reply With Quote
  #2  
Old   
Bruce Momjian
 
Posts: n/a

Default Re: [BUGS] Small bug fix in readline promt handling - 12-28-2005 , 08:08 PM







Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

---------------------------------------------------------------------------


Martin Pitt wrote:
-- Start of PGP signed section.
Quote:
Hi!

When using %[ and %] (prompt length ignore area) in .psqlrc's prompt
formats, psql sends a \001 before the actual readline commands
(RL_PROMPT_{START,END}_IGNORE). This is the way bash handles the
shell's PSx format, but it is not a readline command, but a bash
specific quirk.

Example .psqlrc:
\set PROMPT1 '%[%033[0;35m%]%/@%m%R%#%[%033[0;22m%] '

-> not correctly handled, the cursor will be in the middle of the
prompt.

Attached patch fixes this. This was investigated and patched by Aaron
Schrab <aaron (AT) schrab (DOT) com>, full details at http://bugs.debian.org/343616

Thank you for considering this, and have a merry christmas!

Martin

--
Martin Pitt http://www.piware.de
Ubuntu Developer http://www.ubuntu.com
Debian Developer http://www.debian.org

In a world without walls and fences, who needs Windows and Gates?
[ Attachment, skipping... ]
-- End of PGP section, PGP failed!

--
Bruce Momjian | http://candle.pha.pa.us
pgman (AT) candle (DOT) pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings


Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] Small bug fix in readline promt handling - 01-03-2006 , 05:34 PM



Martin Pitt <martin (AT) piware (DOT) de> writes:
Quote:
When using %[ and %] (prompt length ignore area) in .psqlrc's prompt
formats, psql sends a \001 before the actual readline commands
(RL_PROMPT_{START,END}_IGNORE). This is the way bash handles the
shell's PSx format, but it is not a readline command, but a bash
specific quirk.
Fixed back through 8.0 (we don't seem to have that code in 7.x branches).
Thanks for the report.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.