sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 9719a7e3d22abf02f8bf0dde4a079b7263f0f7e9
parent dc77c5968b046ae7d22d45a8fc78f3774276f807
Author: Richard Ipsum <richardipsum@fastmail.co.uk>
Date:   Thu,  4 Jul 2019 22:49:29 +0100

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]

Diffstat:
Mchgrp.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/chgrp.c b/chgrp.c @@ -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);