bug-tar
[Top][All Lists]
Advanced

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

[Bug-tar] [PATCH] tar: minor error handling for -K and -s scarce options


From: Pavel Raiskup
Subject: [Bug-tar] [PATCH] tar: minor error handling for -K and -s scarce options
Date: Thu, 12 Sep 2013 09:00:51 +0200

Usage of --starting-file and --same-order options make sense only
for reading operations.

* src/tar.c (decode_options): Fail for incompatible subcommand.
(options): Adjust help output.
---
 src/tar.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/tar.c b/src/tar.c
index c3c2459..f870200 100644
--- a/src/tar.c
+++ b/src/tar.c
@@ -532,7 +532,8 @@ static struct argp_option options[] = {
   {"no-same-permissions", NO_SAME_PERMISSIONS_OPTION, 0, 0,
    N_("apply the user's umask when extracting permissions from the archive 
(default for ordinary users)"), GRID+1 },
   {"preserve-order", 's', 0, 0,
-   N_("sort names to extract to match archive"), GRID+1 },
+   N_("member names passed on command line are already sorted "
+      "according to the archive contents"), GRID+1 },
   {"same-order", 0, 0, OPTION_ALIAS, NULL, GRID+1 },
   {"preserve", PRESERVE_OPTION, 0, 0,
    N_("same as both -p and -s"), GRID+1 },
@@ -726,7 +727,7 @@ static struct argp_option options[] = {
   {"hard-dereference", HARD_DEREFERENCE_OPTION, 0, 0,
    N_("follow hard links; archive and dump the files they refer to"), GRID+1 },
   {"starting-file", 'K', N_("MEMBER-NAME"), 0,
-   N_("begin at member MEMBER-NAME in the archive"), GRID+1 },
+   N_("begin at member MEMBER-NAME when reading the archive"), GRID+1 },
   {"newer", 'N', N_("DATE-OR-FILE"), 0,
    N_("only store files newer than DATE-OR-FILE"), GRID+1 },
   {"after-date", 0, 0, OPTION_ALIAS, NULL, GRID+1 },
@@ -2373,6 +2374,13 @@ decode_options (int argc, char **argv)
                      subcommand_string (subcommand_option)));
     }
 
+  if ((starting_file_option || same_order_option)
+      && !IS_SUBCOMMAND_CLASS (SUBCL_READ))
+    USAGE_ERROR ((0, 0,
+                  _("--%s option cannot be used with %s"),
+                  starting_file_option ? "starting-file" : "same-order",
+                  subcommand_string (subcommand_option)));
+
   if (archive_names == 0)
     {
       /* If no archive file name given, try TAPE from the environment, or
-- 
1.8.3.1




reply via email to

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