Report positional options that were used but had no effect during archive creation

* src/names.c (file_selection_option)
(file_selection_option_name): New functions.
(unconsumed_option_push, unconsumed_option_free)
(unconsumed_option_report): New functions.
(name_list_advance): Maintain a list
of eventually unconsumed options during archive creation.
Report unconsumed options, if any.

* tests/positional01.at: New test case.
* tests/positional02.at: New test case.
* tests/positional03.at: New test case.
* tests/Makefile.am: Add new test cases.
* tests/testsuite.at: Likewise.

* NEWS: Document the changes.
* configure.ac: Version 1.29.90
* doc/tar.texi: Document the changes.
This commit is contained in:
Sergey Poznyakoff
2016-05-27 10:39:49 +03:00
parent 20b55f0679
commit 9a33077a7b
9 changed files with 308 additions and 7 deletions

View File

@@ -3879,6 +3879,23 @@ tar -cf a.tar /usr --no-recursion /var/*
tar -cf a.tar --recursion /usr --no-recursion /var/*
@end example
During archive creation, @GNUTAR{} keeps track of positional options
used and arguments affected by them. If it finds out that any such
options are used in an obviously erroneous way, the fact is reported
and exit code is set to 2. E.g.:
@example
@group
$ @kbd{tar -cf a.tar . --exclude '*.o'}
tar: The following options were used after any non-optional
arguments in archive create or update mode. These options are
positional and affect only arguments that follow them. Please,
rearrange them properly.
tar: --exclude '*.o' has no effect
tar: Exiting with failure status due to previous errors
@end group
@end example
The following table summarizes all position-sensitive options.
@table @option