2 # Make sure cp --attributes-only doesn't truncate existing data
4 # Copyright 2012-2023 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
22 printf '1' > file1 || framework_failure_
23 printf '2' > file2 || framework_failure_
24 printf '2' > file2.exp || framework_failure_
26 cp --attributes-only file1 file2 || fail
=1
27 cmp file2 file2.exp || fail
=1
29 # coreutils v8.32 and before would remove destination files
30 # if hardlinked or the source was not a regular file.
31 ln file2 link2 || framework_failure_
32 cp -a --attributes-only file1 file2 || fail
=1
33 cmp file2 file2.exp || fail
=1
35 ln -s file1 sym1 || framework_failure_
36 returns_
1 cp -a --attributes-only sym1 file2 || fail
=1
37 cmp file2 file2.exp || fail
=1
39 # One can still force removal though
40 cp -a --remove-destination --attributes-only sym1 file2 || fail
=1
41 test -L file2 || fail
=1
42 cmp file1 file2 || fail
=1