- if (OPT_NODEREF) chown_func = lchown;
-
- /* First, check if there is a group name here */
- groupName = strchr(*argv, '.'); /* deprecated? */
- if (!groupName)
- groupName = strchr(*argv, ':');
- else
- *groupName = ':'; /* replace '.' with ':' */
-
- /* First, try parsing "user[:[group]]" */
- if (!groupName) { /* "user" */
- ugid.uid = get_ug_id(*argv, xuname2uid);
- } else if (groupName == *argv) { /* ":group" */
- ugid.gid = get_ug_id(groupName + 1, xgroup2gid);
- } else {
- if (!groupName[1]) /* "user:" */
- *groupName = '\0';
- if (!get_uidgid(&ugid, *argv, 1))
- bb_error_msg_and_die("unknown user/group %s", *argv);
+ /* This matches coreutils behavior (almost - see below) */
+ if (OPT_NODEREF
+ /* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
+ IF_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
+ ) {
+ param.chown_func = lchown;