From 1baedc417b85b5ffc3a56e299a75e9e3c49d1d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dorian=20P=C3=A9ron?= <72708393+RenjiSann@users.noreply.github.com> Date: Fri, 30 May 2025 16:29:43 +0200 Subject: [PATCH] ln: don't show error when overwriting a link with -sfn (#7449) * ln: fix #6350 * test(ln): test_symlink_no_deref_dir success has no stderr --- src/uu/ln/src/ln.rs | 1 + tests/by-util/test_ln.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index 3b8ff0d70..0fc72da49 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -301,6 +301,7 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings) show_error!("Could not update {}: {e}", target_dir.quote()); }; } + #[cfg(windows)] if target_dir.is_dir() { // Not sure why but on Windows, the symlink can be // considered as a dir diff --git a/tests/by-util/test_ln.rs b/tests/by-util/test_ln.rs index 9ef25ef08..998595035 100644 --- a/tests/by-util/test_ln.rs +++ b/tests/by-util/test_ln.rs @@ -549,7 +549,11 @@ fn test_symlink_no_deref_dir() { scene.ucmd().args(&["-sn", dir1, link]).fails(); // Try with the no-deref - scene.ucmd().args(&["-sfn", dir1, link]).succeeds(); + scene + .ucmd() + .args(&["-sfn", dir1, link]) + .succeeds() + .no_stderr(); assert!(at.dir_exists(dir1)); assert!(at.dir_exists(dir2)); assert!(at.is_symlink(link));