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 <[EMAIL PROTECTED]>, 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?
diff -ruN postgresql-8.1.1-old/src/bin/psql/prompt.c 
postgresql-8.1.1/src/bin/psql/prompt.c
--- postgresql-8.1.1-old/src/bin/psql/prompt.c  2005-10-15 04:49:40.000000000 
+0200
+++ postgresql-8.1.1/src/bin/psql/prompt.c      2005-12-22 19:12:47.000000000 
+0100
@@ -296,8 +296,7 @@
                                         * characters in prompt strings must be 
marked as such, in
                                         * order to properly display the line 
during editing.
                                         */
-                                       buf[0] = '\001';
-                                       buf[1] = (*p == '[') ? 
RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
+                                       buf[0] = (*p == '[') ? 
RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
 #endif   /* USE_READLINE */
                                        break;
 

Attachment: signature.asc
Description: Digital signature

Reply via email to