Skip to content

Commit

Permalink
feat: expose mv externals + document for nushell
Browse files Browse the repository at this point in the history
  • Loading branch information
PThorpe92 committed Sep 28, 2023
1 parent 0d8f8fc commit 04612f7
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions src/uu/mv/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,31 +440,17 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, opts: &Options) ->
match rename(sourcepath, &targetpath, opts, multi_progress.as_ref()) {
Err(e) if e.to_string().is_empty() => set_exit_code(1),
Err(e) => {
match e.raw_os_error() {
Some(ENOTEMPTY) => {
// The error message was changed to match GNU's decision
// when an issue was filed. These will match when merged upstream.
let e = e
.map_err_context(|| format!("cannot overwrite {}", targetpath.quote()));
match multi_progress {
Some(ref pb) => pb.suspend(|| show!(e)),
None => show!(e),
};
}
_ => {
let e = e.map_err_context(|| {
format!(
"cannot move {} to {}",
sourcepath.quote(),
targetpath.quote()
)
});
match multi_progress {
Some(ref pb) => pb.suspend(|| show!(e)),
None => show!(e),
};
}
}
let e = e.map_err_context(|| {
format!(
"cannot move {} to {}",
sourcepath.quote(),
targetpath.quote()
)
});
match multi_progress {
Some(ref pb) => pb.suspend(|| show!(e)),
None => show!(e),
};
}
Ok(()) => (),
}
Expand Down Expand Up @@ -535,7 +521,7 @@ fn rename(
if is_empty_dir(to) {
fs::remove_dir(to)?;
} else {
return Err(io::Error::from_raw_os_error(ENOTEMPTY));
return Err(io::Error::new(io::ErrorKind::Other, "Directory not empty"));
}
}
}
Expand Down

0 comments on commit 04612f7

Please sign in to comment.