[Top][All Lists]

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

[Bug-tar] Re: tar has strange command line argument parsing

From: Paul Eggert
Subject: [Bug-tar] Re: tar has strange command line argument parsing
Date: Fri, 04 Nov 2005 10:56:21 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

In response to <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=152160>:

Unix version 7 tar has an unusual option syntax.  Options are not
preceded by '-', and you put all the options first and then their
option-arguments.  So you say "tar cvbf 20 x.tar file1 file2".  Just
for fun, in v7 tar, '-' is an option that had no effect, so you also
can say "tar -cvbf 20 x.tar file1 file2" or even "tar -cv---bf- 20
x.tar file1 file2" if you like.

As an extreme example, with Solaris 10 tar (a v7 descendant), the command

  tar --null file1

has a perfectly well-defined meaning; it means to use the 'n', 'u' and
'l' options with the default archive /dev/rmt/0 and the file 'file1'.

GNU tar supports the old v7 tar syntax, but only if you omit the "-".
The idea here is that traditional usage omitted the leading "-", so
that if users employ a leading "-" then they don't want to use the
old-fashioned syntax, they want to use syntax that conforms to the
POSIX and GNU guidelines.  Strictly speaking this is not purely upward
compatible with v7 tar, but we've found it's good enough in practice.

The POSIX guidelines say that options like -b and -f that take
arguments can be spelled either like this, with a space before
the option-arguments:

   tar -cvb 20 -f x.tar file1 file2

or like this, without a space:

   tar -tvb20 -fx.tar file1 file2

Also, POSIX says the operand to an option can begin with "-".  For

  tar -cf -x /etc/motd

creates a file named "-x".  (This is true for Solaris 10 tar too, by
the way.)

I hope this helps to explain the behavior you observed.

There is no standard for the tar command itself, so neither Solaris
nor GNU nor v7 tar is "right".  However, I think GNU tar is more in
the spirit of the modern POSIX standard.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]