Skip to content

fix(cp): honor no-clobber for recursive source links - #1295

Open
Sskift wants to merge 2 commits into
shelljs:mainfrom
Sskift:fix/cp-no-clobber-recursive-links
Open

Sskift wants to merge 2 commits into
shelljs:mainfrom
Sskift:fix/cp-no-clobber-recursive-links

Conversation

@Sskift

@Sskift Sskift commented Nov 2, 2026

Copy link
Copy Markdown

Recursive copies currently apply -n only after the symlink branches. A source link can therefore replace an existing destination file, or overwrite its content when -L follows the link, despite no-clobber being requested.

Check no-clobber before dispatching recursive entries. Continue merging source directories, including directory links followed with -L. When copying the link itself, detect destination entries with lstat so dangling destination links are preserved too.

Regression tests cover copying a directory link over a regular file, following a file link, preserving a dangling destination link, and merging a followed directory while retaining existing content.

Validation on Windows / Node 24:

  • Two initial regressions fail on the original source; the dangling-link regression also fails before its correction.
  • All 79 cp tests and full ESLint pass. The new file-symlink test ran locally and skips only when a Windows host reports EPERM while creating its fixture.
  • Full suite: 658 pass, 6 skip; the same three original Windows failures remain (two command-not-found expectations and a find symlink case).

AI assistance was used to develop and validate this change.

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.

1 participant