Skip to content

Commit

Permalink
Merge pull request uutils#5764 from cakebaker/mv_simplify_condition
Browse files Browse the repository at this point in the history
mv: simplify condition
  • Loading branch information
sylvestre authored Jan 1, 2024
2 parents e2a90c4 + 01e1212 commit 97cb2b2
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/uu/mv/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let mut app = uu_app();
let matches = app.try_get_matches_from_mut(args)?;

if !matches.contains_id(OPT_TARGET_DIRECTORY)
&& matches
.get_many::<OsString>(ARG_FILES)
.map(|f| f.len())
.unwrap_or(0)
== 1
{
let files: Vec<OsString> = matches
.get_many::<OsString>(ARG_FILES)
.unwrap_or_default()
.cloned()
.collect();

if files.len() == 1 && !matches.contains_id(OPT_TARGET_DIRECTORY) {
app.error(
ErrorKind::TooFewValues,
format!(
Expand All @@ -144,12 +144,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.exit();
}

let files: Vec<OsString> = matches
.get_many::<OsString>(ARG_FILES)
.unwrap_or_default()
.cloned()
.collect();

let overwrite_mode = determine_overwrite_mode(&matches);
let backup_mode = backup_control::determine_backup_mode(&matches)?;
let update_mode = update_control::determine_update_mode(&matches);
Expand Down

0 comments on commit 97cb2b2

Please sign in to comment.