summaryrefslogtreecommitdiff
path: root/src/users.c
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2017-11-28 17:32:29 +0100
committerBernhard Voelker <mail@bernhard-voelker.de>2017-11-29 13:27:02 +0100
commit5782a362e17c9c97256b0456f36eb08f767a04e6 (patch)
tree4854035457f7d9b705aaa49f90873c22e136a154 /src/users.c
parentb505dc5734b551b34c9e95c8daa8d574d6d8636e (diff)
downloadcoreutils-5782a362e17c9c97256b0456f36eb08f767a04e6.tar.gz
all: use consistent diagnostics for unknown long options
Previously, e.g. cksum failed to output the offending unknown long option: $ cksum --unknown-opt cksum: invalid option -- '-' Try 'cksum --help' for more information. i.e., it tried to diagnose '-' as short option. Instead, it should diagnose the unknown long option: $ cksum --unknown-opt cksum: unrecognized option '--unknown-opt' Try 'cksum --help' for more information. * src/cksum.c (long_options): Add struct with null entry only. (main): Use it in the getopt_long call. * src/dd.c: Likewise. * src/hostid.c: Likewise. * src/hostname.c: Likewise. * src/link.c: Likewise. * src/logname.c: Likewise. * src/nohup.c: Likewise. * src/sleep.c: Likewise. * src/tsort.c: Likewise. * src/unlink.c: Likewise. * src/uptime.c: Likewise. * src/users.c: Likewise. * src/whoami.c: Likewise. * src/yes.c: Likewise. * NEWS (Improvements): Mention the fix.
Diffstat (limited to 'src/users.c')
-rw-r--r--src/users.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/users.c b/src/users.c
index 7b1d8cdba..4bdebff44 100644
--- a/src/users.c
+++ b/src/users.c
@@ -36,6 +36,11 @@
proper_name ("Joseph Arceneaux"), \
proper_name ("David MacKenzie")
+static struct option const long_options[] =
+{
+ {NULL, 0, NULL, 0}
+};
+
static int
userid_compare (const void *v_a, const void *v_b)
{
@@ -130,7 +135,7 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
usage, AUTHORS, (char const *) NULL);
- if (getopt_long (argc, argv, "", NULL, NULL) != -1)
+ if (getopt_long (argc, argv, "", long_options, NULL) != -1)
usage (EXIT_FAILURE);
switch (argc - optind)