summaryrefslogtreecommitdiff
path: root/src/groups.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2017-07-08 13:01:55 +0200
committerJim Meyering <meyering@fb.com>2017-07-10 10:17:57 +0200
commit83ed6619479710d5979108f85b6bae648bb75061 (patch)
tree8154b55e3b59dbd7fe1aa88f5d716395549fd5b5 /src/groups.c
parented57568ea5fc9dcca8fd4dce00bb3085727e119a (diff)
downloadcoreutils-83ed6619479710d5979108f85b6bae648bb75061.tar.gz
groups: do not exit early
Most programs take care to operate on all command-line-specified operands before exiting. That is an important feature that allows to identify all problems with the first run. However, groups would exit upon the first problematic user name. Bug introduced via commit v6.10-56-g167b8025ac. * src/groups.c (main): Do not exit immediately upon error. * tests/misc/groups-process-all.sh: New file. Test for this. * tests/local.mk (all_tests): Add it. * NEWS (Bug fixes): Mention this.
Diffstat (limited to 'src/groups.c')
-rw-r--r--src/groups.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/groups.c b/src/groups.c
index 0a5c5be88..ccfe8a2d5 100644
--- a/src/groups.c
+++ b/src/groups.c
@@ -122,17 +122,20 @@ main (int argc, char **argv)
else
{
/* At least one argument. Divulge the details of the specified users. */
- while (optind < argc)
+ for ( ; optind < argc; optind++)
{
struct passwd *pwd = getpwnam (argv[optind]);
if (pwd == NULL)
- die (EXIT_FAILURE, 0, _("%s: no such user"),
- quote (argv[optind]));
+ {
+ error (0, 0, _("%s: no such user"), quote (argv[optind]));
+ ok = false;
+ continue;
+ }
ruid = pwd->pw_uid;
rgid = egid = pwd->pw_gid;
printf ("%s : ", argv[optind]);
- if (!print_group_list (argv[optind++], ruid, rgid, egid, true, ' '))
+ if (!print_group_list (argv[optind], ruid, rgid, egid, true, ' '))
ok = false;
putchar ('\n');
}