Skip to content

Commit 4c3e9c8

Browse files
committed
chgrp: split the functions into two
1 parent 9c42b8e commit 4c3e9c8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/uu/chgrp/src/chgrp.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ fn parse_gid_from_str(group: &str) -> Result<u32, String> {
3737
}
3838
}
3939

40-
fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
41-
let mut raw_group: String = String::new();
40+
fn get_dest_gid(matches: &ArgMatches) -> UResult<(Option<u32>, String)> {
41+
let mut raw_group = String::new();
4242
let dest_gid = if let Some(file) = matches.get_one::<String>(options::REFERENCE) {
4343
fs::metadata(file)
4444
.map(|meta| {
@@ -62,6 +62,11 @@ fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
6262
}
6363
}
6464
};
65+
Ok((dest_gid, raw_group))
66+
}
67+
68+
fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
69+
let (dest_gid, raw_group) = get_dest_gid(matches)?;
6570

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

0 commit comments

Comments
 (0)