mirror of
https://github.com/uutils/coreutils
synced 2024-11-05 14:21:32 +00:00
mv: check strictly for hard links first before checking for symlinks to catch a very special case, plus ensure only nobackupmode is considered
This commit is contained in:
parent
c113284a4b
commit
fa11315ce7
1 changed files with 5 additions and 3 deletions
|
@ -25,7 +25,7 @@ use std::path::{Path, PathBuf};
|
|||
use uucore::backup_control::{self, BackupMode};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{set_exit_code, FromIo, UError, UResult, USimpleError, UUsageError};
|
||||
use uucore::fs::are_hardlinks_or_one_way_symlink_to_same_file;
|
||||
use uucore::fs::{are_hardlinks_or_one_way_symlink_to_same_file, are_hardlinks_to_same_file};
|
||||
use uucore::update_control::{self, UpdateMode};
|
||||
use uucore::{format_usage, help_about, help_section, help_usage, prompt_yes, show};
|
||||
|
||||
|
@ -255,8 +255,10 @@ fn handle_two_paths(source: &Path, target: &Path, b: &Behavior) -> UResult<()> {
|
|||
return Err(MvError::NoSuchFile(source.quote().to_string()).into());
|
||||
}
|
||||
|
||||
if (source.eq(target) || are_hardlinks_or_one_way_symlink_to_same_file(source, target))
|
||||
&& b.backup != BackupMode::SimpleBackup
|
||||
if (source.eq(target)
|
||||
|| are_hardlinks_to_same_file(source, target)
|
||||
|| are_hardlinks_or_one_way_symlink_to_same_file(source, target))
|
||||
&& b.backup == BackupMode::NoBackup
|
||||
{
|
||||
if source.eq(Path::new(".")) || source.ends_with("/.") || source.is_file() {
|
||||
return Err(
|
||||
|
|
Loading…
Reference in a new issue