>From 517433b7f8e14b20c73b9ffb7fe3210186bbb611 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Thu, 23 May 2013 11:36:23 +0200 Subject: [PATCH] tar: warn for waste --xattrs-{inc,exc}lude Options --xattrs-include=MASK and --xattrs-exclude=MASK require the --xattrs option to be used. * src/common.h(xattrs_mask_option): New global. * src/tar.c(parse_opt): Increment 'xattrs_mask_option' for each usage of xattrs-{inc,exc}lude. (decode_options): Warn. --- src/common.h | 3 +++ src/tar.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/common.h b/src/common.h index 4f7c19f..3e4dae4 100644 --- a/src/common.h +++ b/src/common.h @@ -269,6 +269,9 @@ GLOBAL int acls_option; /* If positive, save the user and root xattrs. */ GLOBAL int xattrs_option; +/* If nonzero, xattrs-include/xattrs-exclude is used */ +GLOBAL int xattrs_mask_option; + /* When set, strip the given number of file name components from the file name before extracting */ GLOBAL size_t strip_name_components; diff --git a/src/tar.c b/src/tar.c index c29b4fa..b1c9c50 100644 --- a/src/tar.c +++ b/src/tar.c @@ -2215,6 +2215,7 @@ parse_opt (int key, char *arg, struct argp_state *state) case XATTR_INCLUDE: case XATTR_EXCLUDE: xattrs_mask_add (arg, (key == XATTR_INCLUDE)); + xattrs_mask_option ++; break; case RECURSION_OPTION: @@ -2614,6 +2615,10 @@ decode_options (int argc, char **argv) && !READ_LIKE_SUBCOMMAND) USAGE_ERROR ((0, 0, _("--xattrs can be used only on POSIX archives"))); + if (xattrs_mask_option && xattrs_option <= 0) + WARN ((0, 0, _("Options --xattrs-include and --xattrs-exclude do nothing" + " without --xattrs"))); + /* If ready to unlink hierarchies, so we are for simpler files. */ if (recursive_unlink_option) old_files_option = UNLINK_FIRST_OLD_FILES; -- 1.8.1.4