bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

apparent readline bash-2.05a bug, with fix included


From: Barry Bouwsma
Subject: apparent readline bash-2.05a bug, with fix included
Date: Tue, 16 Sep 2003 22:05:35 +0200 (CEST)

[This IS a valid IPv4 e-mail address, trust me, I think, even if mail to me
 may bounce when I'm offline]

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: freebsd4.4
Compiler: cc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='freebsd4.4' -DCONF_MACHTYPE='i386-unknown-freebsd4.4' 
-DCONF_VENDOR='unknown' -DSHELL  -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib 
-O -pipe
uname output: FreeBSD 
dastardly.newsbastards.org.72.27.172.IN-addr.ARPA.NOSPAM.dyndns.dk 4.7-STABLE 
FreeBSD 4.7-STABLE #2: Tue Aug 26 16:49:26 CEST 2003     
address@hidden:/FreeBSD-CURRENT/usr/local/obj/4.7-STABLE/usr/src/sys/FreeLSD  
i386
Machine Type: i386-unknown-freebsd4.4

Bash Version: 2.05a
Patch Level: 0
Release Status: release

Description:
        Bash seems to have problems with multi-line prompts with embedded
        invisible characters, as hinted at by comments in lib/readline/display.c
        line 504-ish.  This doesn't seem easy to fix, after a short time
        thinking about how one might do so, since my prompt often exceeds
        a single line and gets horribly mangled when cycling through the
        history.
        However, one easy-to-fix problem is seen with any prompt containing
        embedded invisible characters, when the line exceeds the terminal
        width, using, say, the incremental `^R' search.  The line will be
        wrapped after 80/79 characters (say), *counting* the invisible
        characters.
        In other words, if the prompt contains, say, ESC [ 7 m  and
        ESC [ 0 m  , then the output line wraps after (say) 72 printable
        characters instead of 80.


Repeat-By:
        Set PS1 to something with some non-printing graphics and plenty
        of printing graphics.  Make sure the line happens to be longer
        than 80 characters or whatever.
        Do a reverse search with `^R'.
        The prompt will wrap before reaching the end of the line.  The
        next prompt without the search will appear normal.  Want my PS1?
        Here, then you can wonder what in the world is wrong with me.
        PS1='address@hidden:\[\e[4m\]\w\[\e[0m\]{\!}\$ '


Fix:
        The following patch seems to solve the premature wrapping:
        in lib/readline/display.c -- cut-n-paste mangles tabs, sorry:

--- display.c-DIST      Tue Oct 30 22:11:44 2001
+++ display.c   Sat Aug 16 16:10:52 2003
@@ -1405,6 +1405,7 @@
 static char *saved_local_prefix;
 static int saved_last_invisible;
 static int saved_visible_length;
+static int saved_invis_chars_first_line;
 void
 rl_save_prompt ()
@@ -1413,6 +1414,9 @@
   saved_local_prefix = local_prompt_prefix;
   saved_last_invisible = prompt_last_invisible;
   saved_visible_length = prompt_visible_length;
+/* XXX HACK */
+  saved_invis_chars_first_line = prompt_invis_chars_first_line;
+  prompt_invis_chars_first_line = 0;
   local_prompt = local_prompt_prefix = (char *)0;
   prompt_last_invisible = prompt_visible_length = 0;
@@ -1428,6 +1432,8 @@
   local_prompt_prefix = saved_local_prefix;
   prompt_last_invisible = saved_last_invisible;
   prompt_visible_length = saved_visible_length;
+/* XXX HACK */
+  prompt_invis_chars_first_line = saved_invis_chars_first_line;
 }
 char *


        I'm still pondering how best to fix things when my prompt
        extends well beyond a single line, and jumping back one display
        width puts one at worst within a non-printing sequence, which
        happens a lot with my brain-damaged PS1 and 70-character-long
        hostname.  No, I mean what source code changes best fix that.

        Apologies if the patch supplied is not needed with the later
        bash releases I haven't bothered to download.

Thanks,
Barry Bouwsma





reply via email to

[Prev in Thread] Current Thread [Next in Thread]