Skip to content

Commit

Permalink
chgrp: split the functions into two
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre committed Jan 23, 2025
1 parent 9c42b8e commit 4c3e9c8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/uu/chgrp/src/chgrp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ fn parse_gid_from_str(group: &str) -> Result<u32, String> {
}
}

fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
let mut raw_group: String = String::new();
fn get_dest_gid(matches: &ArgMatches) -> UResult<(Option<u32>, String)> {
let mut raw_group = String::new();
let dest_gid = if let Some(file) = matches.get_one::<String>(options::REFERENCE) {
fs::metadata(file)
.map(|meta| {
Expand All @@ -62,6 +62,11 @@ fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
}
}
};
Ok((dest_gid, raw_group))
}

fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
let (dest_gid, raw_group) = get_dest_gid(matches)?;

// Handle --from option
let filter = if let Some(from_group) = matches.get_one::<String>(options::FROM) {
Expand Down

0 comments on commit 4c3e9c8

Please sign in to comment.