(parse_obsolescent_option): Recognize and fail for
authorJim Meyering <jim@meyering.net>
Fri, 24 Jan 1997 02:11:52 +0000 (02:11 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 24 Jan 1997 02:11:52 +0000 (02:11 +0000)
more malformed obsolescent options.  Makes for better diagnostics.

src/tail.c

index 153ce70..0d59001 100644 (file)
@@ -917,7 +917,22 @@ parse_obsolescent_option (int argc, const char *const *argv,
     }
 
   if (*p != '\0')
-    return 0;
+    {
+      /* If (argv[1] begins with a `+' or if it begins with `-' followed
+        by a digit), but has an invalid suffix character, give a diagnostic
+        and indicate to caller that this *is* of the obsolescent form,
+        but that it's an invalid option.  */
+      if (t_from_start || n_string)
+       {
+         error (0, 0,
+                _("%c: invalid suffix character in obsolescent option" ), *p);
+         *fail = 1;
+         return 1;
+       }
+
+      /* Otherwise, it might be a valid non-obsolescent option like -n.  */
+      return 0;
+    }
 
   *fail = 0;
   if (n_string == NULL)