Skip to content

fix: preserve relative symlink targets in cp -r - #36

Merged
dsherret merged 1 commit into
mainfrom
fix_cp_symlinks
Sep 1, 2026
Merged

dsherret merged 1 commit into
mainfrom
fix_cp_symlinks

Conversation

@dsherret

@dsherret dsherret commented Sep 1, 2026 •

Copy link
Copy Markdown
Owner

Fixes dsherret/dax#410 (the shell implementation now lives in this repo).

The issue as filed describes dax's old copyDirRecursively silently dropping symlinks during cp -r. This repo's cp is built on Node's fs.promises.cp, which does copy symlinks — but verbatimSymlinks defaults to false, so a relative symlink like real.so.1 -> real.so.1.0.0 was 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 GNU cp -r, which preserves the link text as written.

This passes verbatimSymlinks: true so 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).

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
@dsherret
dsherret merged commit b718c05 into main Sep 1, 2026
5 checks passed
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

Successfully merging this pull request may close these issues.

cp -r's built-in shell command silently drops symlinks

1 participant