From 0ae2f8fe514d10d12e8f640c53abeb1143e1d0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Mon, 13 Feb 2023 19:02:12 +0000 Subject: [PATCH 2/3] tests: allow copying through dangling symlinks on macOS * tests/cp/thru-dangling.sh: fclonefileat() can copy through dangling symlinks robustly, so don't enforce a failure in this case on macOS. --- tests/cp/thru-dangling.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/cp/thru-dangling.sh b/tests/cp/thru-dangling.sh index 1cbb12d11..60d417886 100755 --- a/tests/cp/thru-dangling.sh +++ b/tests/cp/thru-dangling.sh @@ -26,13 +26,19 @@ echo "cp: not writing through dangling symlink 'dangle'" \ > exp-err || framework_failure_ -# Starting with 6.9.90, this usage fails, by default: -for opt in '' '-f'; do - returns_ 1 cp $opt f dangle > err 2>&1 || fail=1 - compare exp-err err || fail=1 - test -f no-such && fail=1 -done - +# macOS may use fclonefileat() which does copy through the dangling symlink +case $host_triplet in + *darwin*) skip_dangling=1 ;; +esac + +if test -z "$skip_dangling"; then + # Starting with 6.9.90, this usage fails, by default: + for opt in '' '-f'; do + returns_ 1 cp $opt f dangle > err 2>&1 || fail=1 + compare exp-err err || fail=1 + test -f no-such && fail=1 + done +fi # But you can set POSIXLY_CORRECT to get the historical behavior. env POSIXLY_CORRECT=1 cp f dangle > out 2>&1 || fail=1 -- 2.26.2