chgrp: Only check errno if getgrnam() fails

This commit is contained in:
sin 2014-12-21 12:12:38 +00:00
parent 09dad0083b
commit 83e94e922e

10
chgrp.c
View File

@ -50,10 +50,12 @@ main(int argc, char *argv[])
errno = 0; errno = 0;
gr = getgrnam(argv[0]); gr = getgrnam(argv[0]);
if (errno) if (!gr) {
eprintf("getgrnam %s:"); if (errno)
else if (!gr) eprintf("getgrnam %s:", argv[0]);
eprintf("getgrnam %s: no such group\n", argv[0]); else
eprintf("getgrnam %s: no such group\n", argv[0]);
}
gid = gr->gr_gid; gid = gr->gr_gid;
while (*++argv) { while (*++argv) {