lvの表示を正しくするパッチ

Ubuntu 10.04でgrep結果をlvすると妙に崩れます。

パッチ適用前は ^[[K のエスケープシーケンスが表示されている
dmesg | grep –color=always eth | lv -c

「ESC(^[、エスケープシーケンス) [ K」が余計に表示されています。これを取り除くために、下のパッチを用意しました。

diff -uNr -x build lv451.orig/src/escape.c lv451/src/escape.c
--- lv451.orig/src/escape.c     2003-11-13 12:08:19.000000000 +0900
+++ lv451/src/escape.c  2010-08-30 22:32:05.990452480 +0900
@@ -62,6 +62,10 @@
 break;
 } while( 'm' != ch );

+    if( 'K' == ch ){
+        return TRUE;
+    }
+
 SIDX = index;

 if( 'm' != ch ){
diff -uNr -x build lv451.orig/src/version.h lv451/src/version.h
--- lv451.orig/src/version.h    2004-01-16 21:25:57.000000000 +0900
+++ lv451/src/version.h 2010-08-30 22:32:56.800403450 +0900
@@ -8,7 +8,7 @@
 #ifndef __VERSION_H__
 #define __VERSION_H__

-#define VERSION                "v.4.51 (Jan.16th,2004)"
+#define VERSION                "v.4.51.sekido (Aug.30th.2010)"

 public void Banner();

「ESC [ K」はANSI escape codeによると、「カーソル位置から文字を消す」意味を持つそうです。

CSI n K    EL — Erase in Line    Erases part of the line. If n is zero (or missing), clear from cursor to the end of the line. If n is one, clear from cursor to beginning of the line. If n is two, clear entire line. Cursor position does not change.

今回のパッチはエスケープシーケンスを無視するものなので、ちゃんとしたパッチではないですが、幾分かlv生活が良くなると思います。

パッチを適用すると ^[[K エスケープシーケンスを無視して表示する
dmesg | grep –color=always eth | lv -c

Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *