View previous topic :: View next topic |
Author |
Message |
Pistos Apprentice
Joined: 29 Jul 2003 Posts: 175 Location: Canada
|
Posted: Thu Mar 16, 2006 4:56 am Post subject: less (pager) showing hex [SOLVED] |
|
|
For some reason, since about a month or two ago, my less pager has been behaving in a very annoying fashion. Whenever there are special (less than 32 ASCII? I'm not sure) characters in what is otherwise supposed to be a text file, it goes into a "hex" mode, rendering my text file essentially unreadable.
Sample:
Code: | 00000000 57 65 64 20 32 33 3a 33 33 3a 35 35 20 7c 20 43 |Wed 23:33:55 | C|
00000010 6f 6e 6e 65 63 74 69 6e 67 20 74 6f 20 65 67 67 |onnecting to egg|
00000020 64 72 6f 70 0a 57 65 64 20 32 33 3a 33 33 3a 35 |drop.Wed 23:33:5|
00000030 35 20 7c 20 4c 6f 67 67 69 6e 67 20 69 6e 74 6f |5 | Logging into|
00000040 20 65 67 67 64 72 6f 70 0a 57 65 64 20 32 33 3a | eggdrop.Wed 23:|
00000050 33 33 3a 35 35 20 7c 20 73 65 6e 64 54 63 6c 3a |33:55 | sendTcl:|
00000060 20 70 72 6f 63 20 72 65 62 79 43 61 6c 6c 20 7b | proc rebyCall {|
00000070 69 6e 73 74 61 6e 63 65 20 6d 65 74 68 6f 64 5f |instance method_|
00000080 6e 61 6d 65 20 7b 61 72 67 6c 69 73 74 20 22 22 |name {arglist ""|
|
I would really really like to know a way to get it to STOP doing this. I've googled around, and read the manpage, I've seen nothing relating less with hex display.
I suspect that my having installed some hex viewers/editors around that time has something to do with it, but I believe I've unemerged them, but the problem persists.
Any help appreciated.
Last edited by Pistos on Thu Mar 16, 2006 3:18 pm; edited 1 time in total |
|
Back to top |
|
|
nahpets Veteran
Joined: 05 Oct 2003 Posts: 1178 Location: Montreal, Canada
|
Posted: Thu Mar 16, 2006 9:02 am Post subject: |
|
|
I also noticed that less started syntax highlighting about a month ago... I did some googling and it seems to be related to 'lesspipe.sh' and possibly 'code2color'. Check out these links for more info:
http://freshmeat.net/projects/lesspipe/
http://www-zeuthen.desy.de/~friebel/unix/lesspipe.html
Hope this points you in the right direction. _________________ Let me guess, you picked out yet another colorful box with a crank that I'm expected to turn and turn until OOP! big shock, a jack pops out and you laugh and the kids laugh and the dog laughs and I die a little inside. |
|
Back to top |
|
|
Pistos Apprentice
Joined: 29 Jul 2003 Posts: 175 Location: Canada
|
Posted: Thu Mar 16, 2006 3:18 pm Post subject: |
|
|
Thank you, thank you, thank you!
Indeed, lesspipe.sh was the culprit. I couldn't quickly find any way to set options to do it, so my "fix" was to comment out the line responsible for calling the hexdump program.
Code: | lesspipe_file() {
local out=$(file -L -- "$1")
case ${out} in
*" ar archive"*) lesspipe "$1" ".a" ;;
*" tar archive"*) lesspipe "$1" ".tar" ;;
*" CAB-Installer"*) lesspipe "$1" ".cab" ;;
*" troff "*) lesspipe "$1" ".man" ;;
*" shared object"*) lesspipe "$1" ".so" ;;
*" Zip archive"*) lesspipe "$1" ".zip" ;;
*" LHa"*archive*) lesspipe "$1" ".lha" ;;
*" ELF "*) readelf -a -- "$1" ;;
# *": data") hexdump -C -- "$1" ;;
*) return 1 ;;
esac
return 0
} |
That commented out line is line 30 in my /usr/bin/lesspipe.sh.
Another alternative for others is to ensure the LESSOPEN environment variable doesn't contain lesspipe. Me personally, I didn't mind the other highlighting and such, I just had a big problem with the hex dumping.
Thanks again! *thumbs up* |
|
Back to top |
|
|
nahpets Veteran
Joined: 05 Oct 2003 Posts: 1178 Location: Montreal, Canada
|
Posted: Thu Mar 16, 2006 9:15 pm Post subject: |
|
|
Ideally, there would be ~/.lessrc that let you configure how you want less to behave. I was having a problem just two days ago where I had a text file with a '.bin' extension and less wouldn't display anything... _________________ Let me guess, you picked out yet another colorful box with a crank that I'm expected to turn and turn until OOP! big shock, a jack pops out and you laugh and the kids laugh and the dog laughs and I die a little inside. |
|
Back to top |
|
|
luddite n00b
Joined: 18 May 2005 Posts: 38
|
Posted: Fri Apr 28, 2006 5:31 pm Post subject: "less" defaults to viewing in HEX mode |
|
|
I'm trying to use "less" to view a text file, and its defaulting to viewing in HEX mode. I'm a bit confused by this, as less has always defaulted to text mode in the past.
Is there a switch that can be permanently set so that less will not default to hex mode? This is a real PITA.
I am using sys-apps/less-385_p4-r2
Thanks. |
|
Back to top |
|
|
chrisruwe Apprentice
Joined: 17 Apr 2006 Posts: 160
|
Posted: Sat Apr 29, 2006 12:11 am Post subject: |
|
|
Is it a less problem, or is it some issue concerning file headers? Try ... you should see a file-header first describing the content. Does your problem appear with any text-file? Even freshly produced (via echo "xxx" >> textfile")? Does the file-command return reasonable results? |
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Sat Apr 29, 2006 2:11 pm Post subject: |
|
|
Merged previous two posts.
Edit: this will give you the 'normal' less behaviour:
Code: | LESSOPEN="" less filename |
_________________ Search | Read | Answer | Report | Strip
Last edited by tomk on Thu Dec 10, 2009 3:58 pm; edited 1 time in total |
|
Back to top |
|
|
luddite n00b
Joined: 18 May 2005 Posts: 38
|
Posted: Sat Apr 29, 2006 7:24 pm Post subject: |
|
|
Well, it looks like the problem has been isolated to lesspipe.sh. But LESS is still displaying plain text in binary format. It doesn't seem right that lesspipe.sh should default to HEX mode on TEXT files. Is this a feature or a bug? |
|
Back to top |
|
|
|