Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 18823 - lesspipe.sh misdetects troff files
Summary: lesspipe.sh misdetects troff files
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
: 63434 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-04-05 18:00 UTC by Wayne Davison
Modified: 2005-04-16 09:42 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
lesspipe.sh improvement (lesspipe.sh.patch,1.06 KB, patch)
2003-04-05 18:09 UTC, Wayne Davison
Details | Diff
Patch, detect troff correctly, decompress if not troff (lesspipe.sh.patch,1.15 KB, patch)
2004-05-26 05:19 UTC, Niels Teglsbo
Details | Diff
Faster patch, detect troff correctly, decompress if not troff (lesspipe.sh.patch,1.32 KB, patch)
2004-05-26 05:51 UTC, Niels Teglsbo
Details | Diff
Make lesspipe.sh-r2 decompress a *.[1-9].gz file if it is not a troff file (lesspipe-r2-r3.diff,532 bytes, patch)
2004-08-20 04:23 UTC, Niels Teglsbo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wayne Davison 2003-04-05 18:00:27 UTC
I think the rules in lesspipe.sh that run groff on various files are more
annoying than they are helpful.  I always run into problems trying to look
at /var/log files (such as syslog.0, or mail.info.1.gz) and also trying to
look at screenlog files (which are named for the window number, such as
screenlog.2) -- the default lesspipe setup completely mangles these files.

I'd prefer to see the groff rules completely removed, but failing that, I'd
like to see them rewritten so that they don't run groff on an ASCII file
(only if the file is identified as "ASCII troff").
Comment 1 Wayne Davison 2003-04-05 18:09:12 UTC
Created attachment 10239 [details, diff]
lesspipe.sh improvement

If the Powers That Be don't wish to remove the *.[1-9] and *.[1-9].gz
cases from the lesspipe.sh file, this patch contains changes that makes
it only work if the file is identified as being a "troff" file.  Fixes
include changing the *.[1-9] rule to look at the right column (3, not 2)
for the string "troff", adding 2>/dev/null to the second groff command,
eliminating the checks for "ASCII" (so that non-troff data doesn't
get mangled), and (!) making the *.[1-9].gz case fall back to just
unzipping the data if it doesn't turn out to be troff data (the old
lesspipe.sh script would pass through the binary data unchanged if it
failed the troff/ASCII check, which was also annoying).
Comment 2 ta2002 2004-02-03 09:28:09 UTC
This bug still exists (and I find it annoying, also). I ran into it
the exact same way that Wayne did (trying to use less on old log
files). I hope some additional attention will get it fixed soon.
Comment 3 Niels Teglsbo 2004-05-26 05:19:37 UTC
Created attachment 32069 [details, diff]
Patch, detect troff correctly, decompress if not troff

This patch includes the changes made by the previous patch.
And it also corrects the detection of troff-files.
Comment 4 Niels Teglsbo 2004-05-26 05:27:57 UTC
This "lesspipe.sh improvement" patch fixes some of the problems,
I can now use less for /var/log/messages.1.gz

But the man page viewing is still broken:

niels@lisa man1 $ zcat zipinfo.1.gz | file -
/dev/stdin: troff or preprocessor input text
niels@lisa man1 $ zcat znew.1.gz | file -
/dev/stdin: ASCII troff or preprocessor input text

znew.1.gz will be piped through groff but zipinfo.1.gz won't.

That is because
gzip -dc $1 2>/dev/null|file -|tr -s ' '|cut -d ' ' -f3
will output "or" for zipinfo.1.gz, and not "troff".

I have made a new patch that also includes correct detection of troff.
Comment 5 Niels Teglsbo 2004-05-26 05:51:43 UTC
Created attachment 32070 [details, diff]
Faster patch, detect troff correctly, decompress if not troff

This patch replaces all earlier posted patches.

It fixes troff recognition and decompresses *[0-9].gz files if they
are not troff files.

The only difference to 32069 is that this patch reuses file output.
So it doesn't decompress the files 2 times to cut out 2 different
words from the file output.
Comment 6 Aron Griffis (RETIRED) gentoo-dev 2004-06-15 13:02:46 UTC
Fixed in less-382-r1, thanks!
Comment 7 Niels Teglsbo 2004-08-20 04:23:34 UTC
Created attachment 37799 [details, diff]
Make lesspipe.sh-r2 decompress a *.[1-9].gz file if it is not a troff file

If I were alowed I would have reopened this bug.

lesspipe.sh-r2 contains this action for *.[1-9].gz files:

  *.[1-9].gz | *.n.gz | *.man.gz)
	[[ $(gzip -dc "$F" 2>/dev/null | file -) == *troff* ]] && \
    gzip -dc "$F" 2>/dev/null | groff -S -s -p -t -e -Tascii -mandoc ;;

Since /var/log/messages.1.gz is not a troff file lesspipe.sh-r2 won't do
anything to it, so less will show the compressed file directly.

Instead lesspipe.sh should gunzip the file if it is not a troff file, which
could be accomplished by changing the above to this:

  *.[1-9].gz | *.n.gz | *.man.gz)
	[[ $(gzip -dc "$F" 2>/dev/null | file -) == *troff* ]] && \
    gzip -dc "$F" 2>/dev/null | groff -S -s -p -t -e -Tascii -mandoc ||
    gzip -dc "$F" 2>/dev/null ;;

And that is what this patch does.
Comment 8 Niels Teglsbo 2004-08-20 04:27:15 UTC
Adding agriffis@gentoo.org as CC.

I'm afraid there is still a problem in lesspipe.sh-r2 where
/var/log/messages.1.gz is not decompressed.
Comment 9 ta2002 2004-09-07 08:30:49 UTC
Still doesn't work. Can someone reopen this?
Comment 10 Seemant Kulleen (RETIRED) gentoo-dev 2004-09-09 10:08:44 UTC
reopening at user request
Comment 11 Seemant Kulleen (RETIRED) gentoo-dev 2004-09-09 10:09:07 UTC
*** Bug 63434 has been marked as a duplicate of this bug. ***
Comment 12 SpanKY gentoo-dev 2004-09-24 20:11:54 UTC
fixed in cvs, thanks
Comment 13 Nik Raub 2005-04-16 09:42:27 UTC
Apparently the fix has still not made it into the portage tree :(
Would someone please take a look at that?