--- chgrp.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/chgrp.c b/chgrp.c index 7ee3553..69c43a4 100644 --- a/chgrp.c +++ b/chgrp.c _AT_@ -44,6 +44,7 @@ int main(int argc, char *argv[]) { struct group *gr; + char *group; struct recursor r = { .fn = chgrp, .hist = NULL, .depth = 0, .maxdepth = 1, .follow = 'P', .flags = 0 }; _AT_@ -66,14 +67,14 @@ main(int argc, char *argv[]) if (argc < 2) usage(); - errno = 0; - if (!(gr = getgrnam(argv[0]))) { - if (errno) - eprintf("getgrnam %s:", argv[0]); - else - eprintf("getgrnam %s: no such group\n", argv[0]); + group = argv[0]; + if (group && *group) { + gr = getgrnam(group); + gid = gr ? gr->gr_gid : estrtonum(group, 0, UINT_MAX); } - gid = gr->gr_gid; + + if (gid == -1) + usage(); for (argc--, argv++; *argv; argc--, argv++) recurse(*argv, NULL, &r); -- 2.21.0Received on Tue Jun 25 2019 - 20:43:24 CEST
This archive was generated by hypermail 2.3.0 : Tue Jun 25 2019 - 20:48:23 CEST