[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: /usr/share/doc/ files and gzip/xz/no compression

On Tue, Aug 16, 2011 at 04:44:07PM +0800, Chow Loong Jin wrote:
> > Am 16.08.2011 02:43, schrieb Russell Coker:
> >> I'd like to see zless work transparently with bzip and xz compressed files.  
> >> There's really no need for three different wrapper programs when the zless 
> >> program can just consult the magic db to determine which decompression program 
> >> to use.
> > 
> >     eval "$(lesspipe)"
> > 
> > you can just "less somegzfile" or "less somebzipfile".  In squeeze you
> > can't use less on a xz compressed file, but I guess that could be added.
> That works when you do "less somefile.gz" or something, but doesn't work out so
> well on gz/bz2 streams, unfortunately. Isn't it possible to detect this based on
> some magic strings at the beginning of the stream?

lesspipe tries to support a long list of compression formats.  On a .pdf, it
will go through pdftotext, on a .iso, it will list the files contained, and
so on.  It'd be tricky to implement all of that as magic rather than
extension checks, especially for twice encapsulated files (.tar.gz, etc).
Doable of course, but on non-seekable streams it'd require some work.

On the other hand, zcat and zless are nothing but thin shell wrappers over
"gzip -cd", without loads of extra functionality lesspipe has.  I'd turn
them into a C program linked against zlib (priority: required), liblzma2
(priority: required) and libbz2 (priority: important, might be dlopened

"zcat" already supports multiple formats: gzip and compress, it's just that
support for uncompressing the latter is included in gzip's binary.  Since
it's not called "gzcat" but generic "zcat", I think that's a better idea
than proliferation of bzcat, xzcat, my-newest-formatcat.

What would you guys say?

1KB		// Yo momma uses IPv4!

Attachment: signature.asc
Description: Digital signature

Reply to: