1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

print_verbose_ownership_retained_as: siplify the function

This commit is contained in:
Sylvestre Ledru 2025-01-12 18:45:58 +01:00
parent 6a5f2aa334
commit 0ba4dad0a6

View file

@ -457,30 +457,18 @@ impl ChownExecutor {
fn print_verbose_ownership_retained_as(&self, path: &Path, uid: u32, gid: Option<u32>) {
if self.verbosity.level == VerbosityLevel::Verbose {
match (self.dest_uid, self.dest_gid, gid) {
(Some(_), Some(_), Some(gid)) => {
println!(
"ownership of {} retained as {}:{}",
path.quote(),
let ownership = match (self.dest_uid, self.dest_gid, gid) {
(Some(_), Some(_), Some(gid)) => format!(
"{}:{}",
entries::uid2usr(uid).unwrap_or_else(|_| uid.to_string()),
entries::gid2grp(gid).unwrap_or_else(|_| gid.to_string()),
);
}
entries::gid2grp(gid).unwrap_or_else(|_| gid.to_string())
),
(None, Some(_), Some(gid)) => {
println!(
"ownership of {} retained as {}",
path.quote(),
entries::gid2grp(gid).unwrap_or_else(|_| gid.to_string()),
);
}
(_, _, _) => {
println!(
"ownership of {} retained as {}",
path.quote(),
entries::uid2usr(uid).unwrap_or_else(|_| uid.to_string()),
);
}
entries::gid2grp(gid).unwrap_or_else(|_| gid.to_string())
}
_ => entries::uid2usr(uid).unwrap_or_else(|_| uid.to_string()),
};
println!("ownership of {} retained as {}", path.quote(), ownership);
}
}
}