All three styles may be intermixed in a single tar command,
so long as the rules for each style are fully
respected1. Old style options and either of the modern styles of
options may be mixed within a single tar command. However,
old style options must be introduced as the first arguments only,
following the rule for old options (old options must appear directly
after the tar command and some white space). Modern options
may be given only after all arguments to the old options have been
collected. If this rule is not respected, a modern option might be
falsely interpreted as the value of the argument to one of the old
style options.
For example, all the following commands are wholly equivalent, and
illustrate the many combinations and orderings of option styles.
tar --create --file=archive.tartar --create -f archive.tartar --create -farchive.tartar --file=archive.tar --createtar --file=archive.tar -ctar -c --file=archive.tartar -c -f archive.tartar -c -farchive.tartar -cf archive.tartar -cfarchive.tartar -f archive.tar --createtar -f archive.tar -ctar -farchive.tar --createtar -farchive.tar -ctar c --file=archive.tartar c -f archive.tartar c -farchive.tartar cf archive.tartar f archive.tar --createtar f archive.tar -ctar fc archive.tar
On the other hand, the following commands are not equivalent to
the previous set:
tar -f -c archive.tartar -fc archive.tartar -fcarchive.tartar -farchive.tarctar cfarchive.tar
These last examples mean something completely different from what the
user intended (judging based on the example in the previous set which
uses long options, whose intent is therefore very clear). The first
four specify that the tar archive would be a file named
-c, ‘c’, ‘carchive.tar’ or ‘archive.tarc’,
respectively. The first two examples also specify a single non-option,
name argument having the value ‘archive.tar’. The last
example contains only old style option letters (repeating option
‘c’ twice), not all of which are meaningful (eg., ‘.’,
‘h’, or ‘i’), with no argument value.
Footnotes
[1] Before GNU tar version 1.11.6,
a bug prevented intermixing old style options with mnemonic options in
some cases.
Published under the terms of the GNU General Public License