[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] nproc: disallow non option command line parameters
From: |
Pádraig Brady |
Subject: |
[PATCH] nproc: disallow non option command line parameters |
Date: |
Thu, 6 Sep 2012 10:49:32 +0100 |
* src/nproc.c (main): Error if any non option parameters.
* NEWS: Mention the change in behavior.
---
NEWS | 4 ++++
src/nproc.c | 7 +++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/NEWS b/NEWS
index 63fa042..995fafb 100644
--- 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
diff --git a/src/nproc.c b/src/nproc.c
index a93ee53..98a1b9a 100644
--- a/src/nproc.c
+++ b/src/nproc.c
@@ -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)
--
1.7.6.4
- [no subject], Pádraig Brady, 2012/09/06
- [PATCH] nproc: disallow non option command line parameters,
Pádraig Brady <=