chown: fix user:group option parsing

Check that either user or group is correctly passed, and adapt
documention according to that.
This commit is contained in:
Quentin Rameau
2015-12-21 19:37:10 +01:00
committed by sin
parent 6e7743eb56
commit a02d66b8fc
2 changed files with 17 additions and 5 deletions

View File

@@ -40,8 +40,9 @@ chownpwgr(const char *path, struct stat *st, void *data, struct recursor *r)
static void
usage(void)
{
eprintf("usage: %s [-h] [-R [-H | -L | -P]] [owner][:[group]] "
"file ...\n", argv0);
eprintf("usage: %s [-h] [-R [-H | -L | -P]] owner[:[group]] file ...\n"
" %s [-h] [-R [-H | -L | -P]] :group file ...\n",
argv0, argv0);
}
int
@@ -99,6 +100,9 @@ main(int argc, char *argv[])
gid = estrtonum(group, 0, UINT_MAX);
}
}
if (uid == (uid_t)-1 && gid == (gid_t)-1)
usage();
for (argc--, argv++; *argv; argc--, argv++)
recurse(*argv, NULL, &r);