This is very annoying, and I've been bitten by it several times.
There are two cases:
1. You try to run "less foo.doc" when catdoc is installed.
-> This works for both MS-Word documents and plain text.
2. You try to run "less foo.doc" when catdoc is not installed.
-> This fails with an error.
I'd expect the second case to work *if* the file is plain text,
otherwise I'd expect it to say something like "The file you're
attempting to view is binary ...blahblah".
So, my solution:
If catdoc is installed
[run catdoc]
else
If the file is ASCII
view it
else
give errror
The patch is attached below. It could be improved to use cat in
both the cases where catdoc is not installed, that way it would
show the binary file - but I couldn't decide whether to do that
or not.
Steve
--
--- lesspipe.orig 2008-02-14 15:05:38.000000000 +0000
+++ lesspipe 2008-02-14 15:06:51.000000000 +0000
@@ -101,8 +101,15 @@
;;
*.doc)
- if [ -x "`which catdoc`" ]; then catdoc "$1"
- else echo "No catdoc available"; fi ;;
+ if [ -x "`which catdoc`" ]; then
+ catdoc "$1"
+ else
+ # no catdoc? read normally if file is text.
+ if ( file "$1" | grep ASCII 2>/dev/null
>/dev/null); then
+ cat "$1"
+ fi
+ echo "No catdoc available";
+ fi ;;
*.gif|*.jpeg|*.jpg|*.pcd|*.png|*.tga|*.tiff|*.tif)
if [ -x "`which identify`" ]; then
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]