1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 12:37:49 +00:00

move cmode rather than mut

This commit is contained in:
Jeong YunWon 2021-06-10 12:37:52 +09:00
parent 797c4a340e
commit 1ac4eb171e

View file

@ -134,23 +134,25 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
Err(err) => crash!(1, "cannot stat attributes of '{}': {}", fref, err), Err(err) => crash!(1, "cannot stat attributes of '{}': {}", fref, err),
}); });
let modes = matches.value_of(options::MODE).unwrap(); // should always be Some because required let modes = matches.value_of(options::MODE).unwrap(); // should always be Some because required
let mut cmode = if mode_had_minus_prefix { let cmode = if mode_had_minus_prefix {
// clap parsing is finished, now put prefix back // clap parsing is finished, now put prefix back
Some(format!("-{}", modes)) format!("-{}", modes)
} else { } else {
Some(modes.to_string()) modes.to_string()
}; };
let mut files: Vec<String> = matches let mut files: Vec<String> = matches
.values_of(options::FILE) .values_of(options::FILE)
.map(|v| v.map(ToString::to_string).collect()) .map(|v| v.map(ToString::to_string).collect())
.unwrap_or_default(); .unwrap_or_default();
if fmode.is_some() { let cmode = if fmode.is_some() {
// "--reference" and MODE are mutually exclusive // "--reference" and MODE are mutually exclusive
// if "--reference" was used MODE needs to be interpreted as another FILE // if "--reference" was used MODE needs to be interpreted as another FILE
// it wasn't possible to implement this behavior directly with clap // it wasn't possible to implement this behavior directly with clap
files.push(cmode.unwrap()); files.push(cmode);
cmode = None; None
} } else {
Some(cmode)
};
let chmoder = Chmoder { let chmoder = Chmoder {
changes, changes,