]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: ln: verify that -f and -i override each other
authorSylvestre Ledru <sylvestre@debian.org>
Thu, 26 Feb 2026 20:58:51 +0000 (21:58 +0100)
committerPádraig Brady <P@draigBrady.com>
Sat, 28 Feb 2026 17:09:42 +0000 (17:09 +0000)
Identified here:
<https://github.com/uutils/coreutils/pull/11129>

* tests/ln/misc.sh: Add the check.
 https://github.com/coreutils/coreutils/pull/199

tests/ln/misc.sh

index 3e46c0899cdae9db5b2e81f4c4eaa0d72d024f06..612cc4bc738d21ebe62cb8ad884ff70c7edeebdd 100755 (executable)
@@ -127,6 +127,27 @@ done
 # Purify probably would have done so.
 ln foo '' 2> /dev/null
 
+# ===================================================
+# Verify that -f and -i override each other, last one wins.
+
+# -sif: force should win (no prompt, overwrite)
+rm -f a b
+touch a b || framework_failure_
+ln -sif a b || fail=1
+test -L b || fail=1
+
+# -sfi: interactive should win; answering "n" should keep b unchanged
+rm -f a b
+touch a b || framework_failure_
+echo n | ln -sfi a b || :
+test -L b && fail=1
+
+# -sfi: interactive should win; answering "y" should create symlink
+rm -f a b
+touch a b || framework_failure_
+echo y | ln -sfi a b || fail=1
+test -L b || fail=1
+
 # ===================================================
 
 Exit $fail