fix: preserve relative symlink targets in cp -r - #36
Merged
Merged
Conversation
Matches GNU cp -r by passing verbatimSymlinks to fs.promises.cp so a relative symlink's target is preserved as written instead of being resolved to an absolute path pointing back into the source directory. Fixes dsherret/dax#410
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes dsherret/dax#410 (the shell implementation now lives in this repo).
The issue as filed describes dax's old
copyDirRecursivelysilently dropping symlinks duringcp -r. This repo's cp is built on Node'sfs.promises.cp, which does copy symlinks — butverbatimSymlinksdefaults to false, so a relative symlink likereal.so.1 -> real.so.1.0.0was copied with its target resolved to an absolute path pointing back into the source directory. That still breaks the issue's use case (remove the source and the SONAME link dangles) and doesn't match GNUcp -r, which preserves the link text as written.This passes
verbatimSymlinks: trueso the target is preserved verbatim. Verified both Deno and Node honour the option. Added a regression test (skipped on Windows like the existing symlink test; verified it passes locally with the skip removed and fails against the unfixed code).