Red Hat Bugzilla – Bug 17456
Suggested lesspipe.sh replacement
Last modified: 2008-05-01 11:37:58 EDT
The lesspipe.sh supplied has several errors: firstly, filenames with
whitespace don't work (although the current rawhide release, less-358-6,
predates the #16777 fix); the wildcard matching is unnecessarily verbose;
the error redirection is unnecessarily given on every line; common file
cases are not grouped together...
So I've rewritten it, and attached it below. My (claimed) improvements are:
- No issues with any filenames; all variable substitutions are protected by
quotes and '--' end of option processing.
- Manpages are read with man, rather than calling groff directly, which
ignored everything in /etc/man.conf
- Manpages are blank-line-squeezed (they still have annoying page breaks,
but that's a different bugzilla)
- All 3 manpage cases are condensed into one
- Compressed tarfiles are grouped into one line, except .tar.bz2, which now
uses tar's 'I' option
- Zipfiles use zipinfo instead of unzip -l. This is a change in output
format, but preferable because zipinfo shows file permissions, compression
method, and uses an "ls -l" style format.
Created attachment 3400 [details]
Suggested replacement for lesspipe.sh
added your new lesspipe.sh in less-358-8. Thanks
Unfortunately, using this version of lesspipe.sh on a file whose name ends in
.1.gz which is not a manpage doesn't work (this happens to me quite often when I
try to view old logs which have been rotated and compressed by logrotate).
The attached version drops back to the default .gz or .bz2 behaviour if the
input file does not contain troff data.
Created attachment 7628 [details]
Version of lesspipe.sh which copes with non-troff .<n>.gz files
OK, I've reopened this bug to submit a fixed version. Some additional comments:
- RedHat added another case for *.?x.gz manpages. I don't think this is the
right way to go, as everyone seems to invent a new section for their project.
For example, on my RH6.2 install, there are *thr.gz, *t.gz, *x.gz, *m.gz,
*qt.gz. man(1) is better suited to reading these sorts of manpages, as it
- RedHat added a cpio handler, which I've slightly rewritten to make it safe
against files which look like options. I've never seen a cpio file with a .cpi
- Experimental support for directory listing (try "less /etc"). The display
format is personal preference, although I appreciate that not everyone will like
the -F option.
- And, of course, the submitted bug. I've added an 'else' case to the manpage
detection to handle compressed rotated logs.
Created attachment 8169 [details]
fixed in the current rawhide version. I didn't add the support for directories.
Fair enough. I actually think Philip's directory listing support is
exceptionally useful, but I guess tastes vary...