aboutsummaryrefslogtreecommitdiffstats
path: root/file_cmds/tests/cp.sh
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2021-05-20 16:22:02 -0400
committerCameron Katri <me@cameronkatri.com>2021-05-20 16:22:02 -0400
commitf5569153b7df6d141164c27040ef0076732f2da7 (patch)
tree338e90c0f5de223bf790b85410838c0bc21cc61d /file_cmds/tests/cp.sh
parent591e92d95c376763dde539fadf0498bd1358073d (diff)
downloadapple_cmds-f5569153b7df6d141164c27040ef0076732f2da7.tar.gz
apple_cmds-f5569153b7df6d141164c27040ef0076732f2da7.tar.zst
apple_cmds-f5569153b7df6d141164c27040ef0076732f2da7.zip
file_cmds: 321.100.10.0.1
Diffstat (limited to 'file_cmds/tests/cp.sh')
-rw-r--r--file_cmds/tests/cp.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/file_cmds/tests/cp.sh b/file_cmds/tests/cp.sh
new file mode 100644
index 0000000..24afa56
--- /dev/null
+++ b/file_cmds/tests/cp.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Regression test for 69452380
+function regression_69452380()
+{
+ echo "Verifying that cp -p preserves symlink's attributes, rather than the attributes of the symlink's target."
+ test_dir=`mktemp -d /tmp/69452380_src_XXXX`
+ touch ${test_dir}/target
+ mkdir ${test_dir}/link_dir
+ # Create symlink (must use relative path for the failure to occur)
+ cd ${test_dir}/link_dir
+ ln -s ../target link
+ # cp (with attribute preservation) the test dir containing both the
+ # target and the link (in a subdirectory) to a new dir.
+ # Prior to 69452380, this failed because we followed the symlink to
+ # try and preserve attributes for a non-existing file, instead of
+ # preserving the attributes of the symlink itself.
+ cp -R -P -p ${test_dir} /tmp/69452380_tgt_${RANDOM}
+}
+
+set -eu -o pipefail
+
+regression_69452380