Please support --no-dereference
From man cp:
-P, --no-dereference
never follow symbolic links in SOURCE
The intended outcome is, rather than treating a symlink to a dir as a directory that should be recursively copied, the destination should itself be a symlink with the same target.
Thank you for creating this utility!
Hi @wez, I'm happy to add this, but I'm not sure I understand your underlying issue ATM. By default xcp does not dereference symlinks; in-fact can't, which is a missing feature. Also cp doesn't dereference by default. e.g:
# mkdir source
# cd source/
# echo data > file
# ln -s file file-link
# ln -s /etc/ .
# mkdir dir
# ln -s dir/ dir-link
# cd dir
# ln -s ../file file-link
# cd ../../
# cp -p --recursive --no-dereference source cp-noderef
# cp -p --recursive source cp-default
# xcp --recursive source xcp-default
# tree source/ cp-default/ cp-noderef/ xcp-default/
source/
├── dir
│ └── file-link -> ../file
├── dir-link -> dir/
├── file
└── file-link -> file
cp-default/
├── dir
│ └── file-link -> ../file
├── dir-link -> dir/
├── file
└── file-link -> file
cp-noderef/
├── dir
│ └── file-link -> ../file
├── dir-link -> dir/
├── file
└── file-link -> file
xcp-default/
├── dir
│ └── file-link -> ../file
├── dir-link -> dir/
├── file
└── file-link -> file
I'm missing something here, can you provide a concrete example of a broken and working copy with cp?
Thank you for creating this utility!
You're welcome! I'm glad somebody finds it useful.
Hi @tarka,
xcpdoes not dereference symlinks
Yes but no, let me show a case. First do preparations:
% xcp --version
xcp 0.24.2
% mkdir -p 1/some 2; touch 1/some/whatever; ln -s /nix/store/00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7 1
% eza -T .
.
├── 1
│ ├── 00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7 -> /nix/store/00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7
│ └── some
│ └── whatever
└── 2
Then try to copy (with progress bar enabled):
% xcp --recursive --target-directory 2 1/some 1/00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7
[------------------------------------------------------------------------------------------------------] 0 B / 15.48 KiB | 0% | 0 B/s | 00:00:00 remaining16:49:39 [ERROR] Error copying: "1/00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7/libexec/coreutils/libstdbuf.so" -> "2/00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7/libexec/coreutils/libstdbuf.so"; aborting.
16:49:39 [ERROR] Received error: Error during copy: Permission denied (os error 13)
Error: Error during copy: Permission denied (os error 13)
% eza -T .
.
├── 1
│ ├── 00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7 -> /nix/store/00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7
│ └── some
│ └── whatever
└── 2
├── 00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7 -> /nix/store/00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7
└── some
└── whatever
And repeat with no progres bar:
% rm -rf 2; mkdir 2
% xcp --no-progress --recursive --target-directory 2 1/some 1/00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7
% eza -T .
.
├── 1
│ ├── 00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7 -> /nix/store/00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7
│ └── some
│ └── whatever
└── 2
├── 00bc157nm93q5fjz551fwk60ihlbilvj-coreutils-9.7
│ ├── bin
│ │ ├── [ -> coreutils
│ │ ├── b2sum -> coreutils
│ │ ├── base32 -> coreutils
│ │ ├── base64 -> coreutils
│ │ ├── basename -> coreutils
│ │ ├── basenc -> coreutils
…