mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
ln: remove redundant force
flag
This information is already encoded in the `OverwriteMode` enum.
This commit is contained in:
parent
efa89de463
commit
87570bbc10
1 changed files with 41 additions and 41 deletions
|
@ -27,7 +27,6 @@ use uucore::fs::{canonicalize, CanonicalizeMode};
|
|||
pub struct Settings {
|
||||
overwrite: OverwriteMode,
|
||||
backup: BackupMode,
|
||||
force: bool,
|
||||
suffix: String,
|
||||
symbolic: bool,
|
||||
relative: bool,
|
||||
|
@ -244,7 +243,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
|||
let settings = Settings {
|
||||
overwrite: overwrite_mode,
|
||||
backup: backup_mode,
|
||||
force: matches.is_present(OPT_FORCE),
|
||||
suffix: backup_suffix.to_string(),
|
||||
symbolic: matches.is_present(OPT_SYMBOLIC),
|
||||
relative: matches.is_present(OPT_RELATIVE),
|
||||
|
@ -311,7 +309,8 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings)
|
|||
|
||||
let mut all_successful = true;
|
||||
for srcpath in files.iter() {
|
||||
let targetpath = if settings.no_dereference && settings.force {
|
||||
let targetpath =
|
||||
if settings.no_dereference && matches!(settings.overwrite, OverwriteMode::Force) {
|
||||
// In that case, we don't want to do link resolution
|
||||
// We need to clean the target
|
||||
if is_symlink(target_dir) {
|
||||
|
@ -422,7 +421,8 @@ fn link(src: &Path, dst: &Path, settings: &Settings) -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
if settings.no_dereference && settings.force && dst.exists() {
|
||||
if settings.no_dereference && matches!(settings.overwrite, OverwriteMode::Force) && dst.exists()
|
||||
{
|
||||
fs::remove_file(dst)?;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue