(main): Warn when -r is specified before --archive (-a).
authorJim Meyering <jim@meyering.net>
Sat, 2 Mar 2002 17:23:34 +0000 (17:23 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 2 Mar 2002 17:23:34 +0000 (17:23 +0000)
src/cp.c

index d2cedcf..0a81d97 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -836,7 +836,9 @@ main (int argc, char **argv)
   struct cp_options x;
   char *target_directory = NULL;
   bool seen_option_a = false;
+  bool seen_option_r = false;
   bool seen_option_a_then_r = false;
+  bool seen_option_r_then_a = false;
 
   program_name = argv[0];
   setlocale (LC_ALL, "");
@@ -874,6 +876,8 @@ main (int argc, char **argv)
          x.recursive = 1;
          x.copy_as_regular = 0;
          seen_option_a = true;
+         if (seen_option_r)
+           seen_option_r_then_a = true;
          break;
 
        case 'V':  /* FIXME: this is deprecated.  Remove it in 2001.  */
@@ -948,6 +952,7 @@ main (int argc, char **argv)
        case 'r':
          x.recursive = 1;
          x.copy_as_regular = 1;
+         seen_option_r = true;
          if (seen_option_a)
            seen_option_a_then_r = true;
          break;
@@ -1017,6 +1022,10 @@ main (int argc, char **argv)
       usage (1);
     }
 
+  if (seen_option_r_then_a)
+    error (0, 0,
+          _("WARNING: -r has no effect when specified before --archive (-a)"));
+
   if (x.hard_link && x.symbolic_link)
     {
       error (0, 0, _("cannot make both hard and symbolic links"));