nALFS and Busybox

Joerg W Mittag Joerg.Mittag at Web.De
Wed Sep 10 08:45:23 PDT 2003


Neven Has wrote:
> On Mon, Sep 08, 2003 at 11:50:53AM +0200, Joerg W Mittag wrote:
>> Actually, standard tar does neither have a 'z' option nor a 'j'
>> option and does not allow dashes prepended to options (see:
>> http://opengroup.org/onlinepubs/007908799/xcu/tar.html). The
>> portable way would be something like 'gzip -d %s | tar xvf -'.
> Yes, it used to be "bzip2 -dc %s | tar xv" for .tar.bz2 files, but I
> remember there were some problems with that.  The whole thing will
> return 0, even in case when bzip2 doesn't exist.  We could check for
> bzip2 separately to solve that; I don't remember if that was the
> only reason for switching to --use-compress-prog.
>
> I would love to avoid using pipes, but I'm not sure if that's
> possible in portable way?

I think that depends on your definition of "portable".

In Single Unix Specification v3, tar is deprecated in favor of pax,
which doesn't have any decompression options - and is not in very
widespread use, unfortunately.

In SUSv2, tar doesn't have any decompression options.

In Linux Standard Base 1.3, tar has a -z option and deprecated
--bzip2, --ungzip, --gzip and --use-compress-program options. The same
is true for the current draft of LSB 2.0

The most widely used tars on Linux are probably GNU tar, BusyBox tar
and Star. The former two support z and j options. The latter detects
and decompresses compressed archives automagically and has only dummy
z and j options that spit out something like: "Hey, I'm not stupid GNU
tar, so please stop bugging me with GNU options." Unfortunately, I
don't remember if Star continues after this message or returns an
error and expects the user to call it again w/o decompression options.

So, if you think that 99,9% of all Linux distributions is portable
enough, then use -z and -j. And you can probably satisfy most of the
other 0,1% where tar is a POSIX tar by checking for the existence of a
gtar executable.

jwm




More information about the alfs-discuss mailing list