Skip to content

fix: make cp -r with a trailing /. copy directory contents like GNU cp - #30

Merged
dsherret merged 1 commit into
mainfrom
cp-trailing-dot
Jul 13, 2026
Merged

fix: make cp -r with a trailing /. copy directory contents like GNU cp#30
dsherret merged 1 commit into
mainfrom
cp-trailing-dot

Conversation

@dsherret

Copy link
Copy Markdown
Owner

Fixes the same bug as denoland/deno_task_shell#176.

cp -r public/. dist/ created dist/public instead of merging the contents of public into dist. The source path was resolved (normalizing the trailing /. away) before computing the destination as dist/ + basename. GNU cp uses the last component of the path as written — for public/. that's ., so the target resolves to dist/. = dist itself.

Changes:

  • calculateDestinationPath now takes the path as specified on the command line, so a trailing /. merges directory contents into the destination (hidden files included)
  • since the destination logic is shared with mv, added a guard so mv public/. dist errors with refusing to move '.' or '..' like GNU mv instead of potentially renaming over an empty destination directory

@dsherret
dsherret merged commit 0f6c382 into main Jul 13, 2026
4 checks passed
@dsherret
dsherret deleted the cp-trailing-dot branch July 13, 2026 16:59
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