Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please support --no-dereference #52

Open
wez opened this issue Jun 19, 2024 · 1 comment
Open

Please support --no-dereference #52

wez opened this issue Jun 19, 2024 · 1 comment

Comments

@wez
Copy link

wez commented Jun 19, 2024

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!

wez added a commit to KumoCorp/kumomta that referenced this issue Jun 19, 2024
We need to avoid recursively copying any symlinks-to-dirs as
directories. We can do that with cp, but the parallel xcp utility
doesn't support the --no-dereference flag at this time.

refs: tarka/xcp#52
@tarka
Copy link
Owner

tarka commented Jun 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants