chgrp: parse gid if operand is not group name

[Michael Forney: Removed unnecessary `gid == -1` check, changed *argv
 to argv[0] to match existing code]
This commit is contained in:
Richard Ipsum 2019-07-04 22:49:29 +01:00 committed by Michael Forney
parent dc77c5968b
commit 9719a7e3d2

View File

@ -67,13 +67,13 @@ main(int argc, char *argv[])
usage();
errno = 0;
if (!(gr = getgrnam(argv[0]))) {
if ((gr = getgrnam(argv[0]))) {
gid = gr->gr_gid;
} else {
if (errno)
eprintf("getgrnam %s:", argv[0]);
else
eprintf("getgrnam %s: no such group\n", argv[0]);
gid = estrtonum(argv[0], 0, UINT_MAX);
}
gid = gr->gr_gid;
for (argc--, argv++; *argv; argc--, argv++)
recurse(*argv, NULL, &r);