]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
nproc: disallow non option command line parameters
authorPádraig Brady <P@draigBrady.com>
Thu, 6 Sep 2012 09:34:00 +0000 (10:34 +0100)
committerPádraig Brady <P@draigBrady.com>
Thu, 6 Sep 2012 09:46:35 +0000 (10:46 +0100)
* src/nproc.c (main): Error if any non option parameters.
* NEWS: Mention the change in behavior.

NEWS
src/nproc.c

diff --git a/NEWS b/NEWS
index 63fa042a33d28aeb760a29b7eb3cf0578a9d3743..995fafb77699753cca284a31c73903c225c7b52f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,10 @@ GNU coreutils NEWS                                    -*- outline -*-
   "Too many levels of symbolic links" diagnostic.
   [bug introduced in coreutils-8.6]
 
+** Changes in behavior
+
+  nproc now diagnoses with an error, non option command line parameters.
+
 ** Improvements
 
   stat and tail work better with ZFS and VZFS.  stat -f --format=%T now
index a93ee536bbb1948379de148acf1b348583426fed..98a1b9aca6af1a05ea2d6e568656d8d4dbf9384f 100644 (file)
@@ -24,6 +24,7 @@
 #include "system.h"
 #include "error.h"
 #include "nproc.h"
+#include "quote.h"
 #include "xstrtol.h"
 
 /* The official name of this program (e.g., no 'g' prefix).  */
@@ -113,6 +114,12 @@ main (int argc, char **argv)
         }
     }
 
+  if (argc != optind)
+    {
+      error (0, 0, _("extra operand %s"), quote (argv[optind]));
+      usage (EXIT_FAILURE);
+    }
+
   nproc = num_processors (mode);
 
   if (ignore < nproc)