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:
parent
dc77c5968b
commit
9719a7e3d2
8
chgrp.c
8
chgrp.c
@ -67,13 +67,13 @@ main(int argc, char *argv[])
|
|||||||
usage();
|
usage();
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (!(gr = getgrnam(argv[0]))) {
|
if ((gr = getgrnam(argv[0]))) {
|
||||||
|
gid = gr->gr_gid;
|
||||||
|
} else {
|
||||||
if (errno)
|
if (errno)
|
||||||
eprintf("getgrnam %s:", argv[0]);
|
eprintf("getgrnam %s:", argv[0]);
|
||||||
else
|
gid = estrtonum(argv[0], 0, UINT_MAX);
|
||||||
eprintf("getgrnam %s: no such group\n", argv[0]);
|
|
||||||
}
|
}
|
||||||
gid = gr->gr_gid;
|
|
||||||
|
|
||||||
for (argc--, argv++; *argv; argc--, argv++)
|
for (argc--, argv++; *argv; argc--, argv++)
|
||||||
recurse(*argv, NULL, &r);
|
recurse(*argv, NULL, &r);
|
||||||
|
Loading…
Reference in New Issue
Block a user