Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/uu/chown/src/chown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ fn parse_gid(group: &str, spec: &str) -> UResult<Option<u32>> {
/// * `"owner:group"`,
/// * `"owner"`,
/// * `":group"`,
/// * `"owner:"`,
///
/// and the owner or group can be specified either as an ID or a
/// name. The `sep` argument specifies which character to use as a
Expand Down Expand Up @@ -230,7 +231,13 @@ fn parse_spec(spec: &str, sep: char) -> UResult<(Option<u32>, Option<u32>)> {
));
}

Ok((uid, gid))
if gid.is_none() && !user.is_empty() && spec.ends_with(':') {
// we have input of the form user: and should change the group to the users login group as
// per GNU
Ok((uid, Some(entries::usr2gid(user)?)))
} else {
Ok((uid, gid))
}
}

#[cfg(test)]
Expand Down
Loading