You are not logged in.

#1 2009-07-06 16:17:11

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

[patch] fix mangled prompt issue with urxvt in tiling WMs

so last night, i took it upon myself to fix a nagging issue i've been having with urxvt.  basically, when first launched, urxvt would mangle the prompt; it would print the first line of my two liner twice, or move the cursor 10 characters to the right, just ugly.  hitting clear or any command would fix it but i figured if xterm can get it right, what's wrong with urxvt?

you may be at risk if:

-- you use bash as your shell
-- you use urxvt (any version) as your terminal
-- you use some form of WM (usually tilers) that quickly resizes programs immediately upon launch
-- you use a multi-line PS1

why this is happening:

basically, urxvt is setup to handle a SIGWINCH differently than other terminals, and bash is setup to send said SIGWINCH at an inconvenient time if the window is resized before the prompt finishes printing.  urxvt dev's say it's a bash issue that will be fixed soon... but nonetheless, just commenting out a few lines of urxvt source code solved it for me.

i've tried my hand at creating a patch for this.  (it was simple, so i thought it'd be a good first attempt).

rxvt_fixprompt.patch:

--- src/command.C.old   2009-07-06 11:50:09.000000000 -0400
+++ src/command.C       2009-07-06 11:49:10.000000000 -0400
@@ -2205,9 +2205,9 @@

       if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT))
         {
-          if (expect_false (!seen_input))
-            {
-              seen_input = 1;
+          //if (expect_false (!seen_input))
+          //  {
+          //    seen_input = 1;
               // many badly-written programs (e.g. jed) contain a race condition:
               // they first read the screensize and then install a SIGWINCH handler.
               // some window managers resize the window early, and these programs
@@ -2215,9 +2215,9 @@
               // unfortunately other programs are even more buggy and dislike
               // being sent SIGWINCH, so only do it when we were in fact being
               // resized.
-              if (seen_resize && cmd_pid)
-                kill (-cmd_pid, SIGWINCH);
-            }
+           //   if (seen_resize && cmd_pid)
+           //     kill (-cmd_pid, SIGWINCH);
+           // }

           /* Read a text string from the input buffer */
           wchar_t buf[UBUFSIZ];

a wget'able link can be found here.  as i said, this is my first attempt at making a patch so if i screwed it up, please tell me how to fix it and i will.

hope someone else finds this useful.

Offline

#2 2009-07-06 22:10:07

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

Thanks for the patch brisbin33! There is one problem though - I've tried to create a PKGBUILD including the patch and it won't compile after applying the patch succesfully. So, do you have a viable PKGBUILD including this patch?

Actually I just hacked the PKGBUILD from abs to so it changes directories and applies the patch and cd's back and runs ./configure.

Offline

#3 2009-07-06 22:14:37

arkham
Member
From: Stockholm
Registered: 2008-10-26
Posts: 516
Website

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

It is a bash4 bug; urxvt sends the sigwinch to fix some buggy ncurses programs.
Here is the patch that solves the problem:
http://www.mail-archive.com/bug-bash@gn … 05464.html

roll

Last edited by arkham (2009-07-06 22:16:43)


"I'm Winston Wolfe. I solve problems."

~ Need moar games? [arch-games] ~ [aurcheck] AUR haz updates? ~

Offline

#4 2009-07-06 22:23:50

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,549

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

Thanks very much for your efforts, brisbin smile

Offline

#5 2009-07-06 22:47:11

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

Ashren wrote:

Thanks for the patch brisbin33! There is one problem though - I've tried to create a PKGBUILD including the patch and it won't compile after applying the patch succesfully. So, do you have a viable PKGBUILD including this patch?

Actually I just hacked the PKGBUILD from abs to so it changes directories and applies the patch and cd's back and runs ./configure.

sorry ashren, i didn't make a PKGBUILD (i actually commented the lines by hand before building, then made the patch later as an exercise).  i used the naming convention from the gcc patch in the rxvt-unicode-256color PKGBUILD (src/command.C.old, src/command.C) i figured that would work? i guess not.

thanks for the bash patch arkam, that's probably the more legit fix for this issue.

edit/ so you're not left out... thanks for the thanks ranguvar

Last edited by brisbin33 (2009-07-06 22:48:21)

Offline

#6 2009-07-07 00:37:59

Mr Pink57
Member
From: a van down by the river
Registered: 2009-05-30
Posts: 91

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

Has anyone thought of just making a 256 color urxvt with this patch included in the AUR?  It doesnt sound like it would effect urxvt in any other WM.

pink


Even a broken clock is right twice a day.

Diplomacy without force is like music without instruments.

Offline

#7 2009-07-07 00:57:17

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

arkham wrote:

It is a bash4 bug; urxvt sends the sigwinch to fix some buggy ncurses programs.
Here is the patch that solves the problem:
http://www.mail-archive.com/bug-bash@gn … 05464.html

roll

This is not a bash4 bug.  This issue has been around for quite some time for me and I use zsh.

brisbin33, I'll try this out as soon as I get a chance.  Thanks!


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#8 2009-07-07 06:24:24

lswest
Member
From: Munich, Germany
Registered: 2008-06-14
Posts: 456
Website

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

rson451 wrote:

This is not a bash4 bug.  This issue has been around for quite some time for me and I use zsh.

brisbin33, I'll try this out as soon as I get a chance.  Thanks!

Yup, same here, the problem happens with Zsh for me too and urxvt, so I'll give the patch a go too once I get to my Arch system again.  Thanks for the patch! (this issue has been bugging me for a long time).


Lswest <- the first letter of my username is a lowercase "L".
"...the Linux philosophy is "laugh in the face of danger". Oops. Wrong one. "Do it yourself". That's it." - Linus Torvalds

Offline

#9 2009-07-07 07:22:55

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

I also use ZSH, and am plagued by this bug. However, urxvt does not compile with the patch applied.


Cthulhu For President!

Offline

#10 2009-07-07 09:16:43

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

No, it does not seem to compile. Which version of rxvt-unicode are you compiling brisbin33?

Offline

#11 2009-07-07 10:40:21

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

I can't get urxvt to compile before this patch, I dont think this is his issue.  (I'm using rxvt-unicode-256color from the AUR though)


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#12 2009-07-07 11:29:28

xduugu
Member
Registered: 2008-10-16
Posts: 292

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

urxvt needs a patch for gcc 4.4: http://cvs.fedoraproject.org/viewvc/dev … vision=1.1

@brisbin33: thanks for the patch, works fine here.

Offline

#13 2009-07-07 12:11:28

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

xduugu wrote:

Ah, thanks.

ZSH still has the bug, though. Looks like this patch fixes Bash's issue only.


Cthulhu For President!

Offline

#14 2009-07-07 13:42:42

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

just be clear...

i hand edited command.C from rxvt-unicode-256color 9.06-3 in the AUR.  after this, it compiled fine for me (64 bit).  i then took a diff and called them src/command.C.old and src/command.C and called that the patch.

it simply comments lines 2208-2220 of command.C

i'm glad it's working for some.

Last edited by brisbin33 (2009-07-07 15:01:04)

Offline

#15 2009-07-07 20:04:39

Barghest
Member
From: Hanau/Germany
Registered: 2008-01-03
Posts: 563

Re: [patch] fix mangled prompt issue with urxvt in tiling WMs

Thanks for that brisbin.

I just downloaded the patch file, adjusted the PKGBUILD and didn't notice the problem so far.

It was just a small issue, but as you said nagging.

Offline

Board footer

Powered by FluxBB