From 4c3e9c893ac45e524770bc4f44e167fbe4ae8a5d Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 19 Jan 2025 23:22:55 +0100 Subject: [PATCH] chgrp: split the functions into two --- src/uu/chgrp/src/chgrp.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/uu/chgrp/src/chgrp.rs b/src/uu/chgrp/src/chgrp.rs index f93fff646d..07d34071cf 100644 --- a/src/uu/chgrp/src/chgrp.rs +++ b/src/uu/chgrp/src/chgrp.rs @@ -37,8 +37,8 @@ fn parse_gid_from_str(group: &str) -> Result { } } -fn parse_gid_and_uid(matches: &ArgMatches) -> UResult { - let mut raw_group: String = String::new(); +fn get_dest_gid(matches: &ArgMatches) -> UResult<(Option, String)> { + let mut raw_group = String::new(); let dest_gid = if let Some(file) = matches.get_one::(options::REFERENCE) { fs::metadata(file) .map(|meta| { @@ -62,6 +62,11 @@ fn parse_gid_and_uid(matches: &ArgMatches) -> UResult { } } }; + Ok((dest_gid, raw_group)) +} + +fn parse_gid_and_uid(matches: &ArgMatches) -> UResult { + let (dest_gid, raw_group) = get_dest_gid(matches)?; // Handle --from option let filter = if let Some(from_group) = matches.get_one::(options::FROM) {