(tar)Old Options
Next:
Mixing Styles Prev:
Short Options Up:
Option Styles
Old Option Style
----------------
*(This message will disappear, once this node revised.)*
Old options are single letters not preceeded by any dash at all, and
appearing *only* in the position immediately following the `tar'
keyword in the command, after some white space. The letter of an old
option is exactly the same letter as the corresponding short option.
For example, the old option `t' is the same as the short option `-t',
and consequently, the same as long option `--list' (`-t').
As far as we know, all `tar' programs, GNU and non-GNU, support old
options. GNU `tar' supports them not only for historical reasons, but
also because many people are used to them.
All old options should be written as a single argument, without
separating spaces, by lumping together all letters specifying these
options. This set of letters should be the first to appear on the
command line, after the `tar' program name; old options cannot appear
anywhere else. Then, for any old option required an argument, the
argument should follow on the command line. Arguments to the options
should appear in the same order as the letters to which they
correspond. The `tar' command synopsis might be rewritten:
tar LETTER... [ARGUMENT]... [OPTION]... [NAME]...
when old options are being used.
This command syntax is useful because it lets you type the single
letter forms of the operation and options as a single argument to `tar',
without writing preceding `-'s or inserting spaces between letters.
`tar cv' or `tar -cv' are equivalent to `tar -c -v'.
For compatibility with Unix `tar', the first argument can contain an
option letter (or a cluster of option letters) *not* introduced by a
dash; for example, `tar cv' specifies the option `-v' in addition to
the command `-c'. When options that need arguments are given together
with the command, all the associated arguments follow, in the same
order as the options. Thus, the example above could also be written in
the old style as follows:
tar cvbf 20 /dev/rmt0
Here `20' is the argument of `-b' and `/dev/rmt0' is the argument of
`-f'.
On the other hand, this old style syntax makes it difficult to match
option letters with their corresponding arguments, and is often
confusing. In the command `tar cvbf 20 /dev/rmt0', for example, `20'
is the argument for `-b', `/dev/rmt0' is the argument for `-f', and
`-v' does not have a corresponding argument. Even using short options
like in `tar -c -v -b 20 -f /dev/rmt0' is clearer, putting all
arguments next to the option they pertain to.
If you want to reorder the letters in the old option argument, be
sure to appropriately reorder any corresponding argument.
This old way of writing `tar' options can surprise even experienced
users. For example, the two commands:
tar cfz archive.tar.gz file
tar -cfz archive.tar.gz file
are quite different. The first example uses `archive.tar.gz' as the
value for option `f' and recognizes the option `z'. The second
example, however, uses `z' as the value for option `f'--probably not
what was intended. (I find it quite inelegant that `getopt' batches
the remaining `z' as the value for `f'. I think that clarity dictates
that clustering of option letters, when some require arguments, should
be diagnosed and disallowed. But compatibility with traditional
systems dictates it.) This second example could be corrected in many
ways, among which:
tar -czf archive.tar.gz file
tar -cf archive.tar.gz -z file
tar cf archive.tar.gz -z file
automatically generated by info2www version 1.2