]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
.
authorJim Meyering <jim@meyering.net>
Sun, 19 Jun 1994 04:27:52 +0000 (04:27 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 19 Jun 1994 04:27:52 +0000 (04:27 +0000)
src/nice.c

index 0d3dcbb76921e057dc81f589b80a0d583bd902a3..d0db40018a59f8e37e2efbe0ff2b65843ee350ba 100644 (file)
@@ -80,13 +80,35 @@ main (argc, argv)
 
   program_name = argv[0];
 
+  /* Inhibit the error message getopt would otherwise give for
+     unrecognized options.  */
+  opterr = 0;
+
   while ((optc = getopt_long (argc, argv, "+0123456789-n:", longopts,
                              (int *) 0)) != EOF)
     {
+      char *s;
+
       switch (optc)
        {
        case '?':
-         usage (1);
+         /* Determine whether this is an option like `--5'.
+            If so, treat it like `-n -5'.  */
+         s = argv[optind - 1];
+         /* Make sure s[1..] is a valid negative integer.
+            Test/convert `s+1' rather than `s+2' so we reject options
+            like `---5' as unrecognized.  */
+         if (s[1] == '-' && isinteger (s + 1))
+           {
+             adjustment = atoi (s + 1);
+             adjustment_given = 1;
+           }
+         else
+           {
+             error (0, 0, "unrecognized option `%s'", s);
+             usage (1);
+           }
+         break;
 
        case 0:
          break;