Hello,

Working on:

https://github.com/uutils/coreutils/issues/8830

i noticed that this case isn't covered by the GNU testsuite.

$ mkdir dir
$ touch file
$ ln file dir
$ ln -f file dir

The existing patch fixes that

Cheers
S

From e094ba2978d2e93cf69207fc690d47e3fcc9322f Mon Sep 17 00:00:00 2001
From: Sylvestre Ledru <[email protected]>
Date: Fri, 10 Oct 2025 13:38:33 +0200
Subject: [PATCH] tests: ln -f should override the existing symlink

Identified here:
https://github.com/uutils/coreutils/issues/8830

* tests/ln/misc.sh: add the check
---
 tests/ln/misc.sh | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tests/ln/misc.sh b/tests/ln/misc.sh
index bae731ef4..79ea5abe5 100755
--- a/tests/ln/misc.sh
+++ b/tests/ln/misc.sh
@@ -96,6 +96,14 @@ ln --no-dereference -fs "$af" $ld || fail=1
 test -f $ld || fail=1
 rm -rf $d $f $ld
 
+# -f on a existing file should not generate an error
+rm -rf $d $f
+touch $f || framework_failure_
+mkdir $d || framework_failure_
+ln $f $d
+ln -f $f $d || fail=1
+test -d $d || fail=1
+
 # Try to create a symlink with backup where the destination file exists
 # and the backup file name is a hard link to the destination file.
 touch a b || framework_failure_
-- 
2.47.2

Reply via email to