shelljs / shelljs/shx

shx cp -r Creates nested recursive directories

Open
#209 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

fix shelljs
Dominant language
JavaScript
Stars
1.9k
Forks
51
Avg merge
3d 2h
Merged PRs (30d)
1

Description

There's a difference between the bash cp -r behavior and shx cp -r when trying to copy a directory into itself:

Create a directory ./dist with a single file in it (e.g., "test.txt") and run:

  1. (in bash) cp -ur "./dist" "./dist/prod"
  2. (with npm) "shx cp -ur "./dist" "./dist/prod""

Test 1. will result in a message saying "cp: cannot copy a directory, './dist/', into itself, './dist/prod'" but test 2. will result in a nested directory structure with a large amount of layers, each ./dist/prod subdirectory will contain another "/prod" subdirectory recursively.

Using shx version "0.3.4"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with bash cp -ur and shx cp -ur using ./dist and ./dist/prod, then trace shx's copy-command entry point. Compare how each handles copying a directory into itself. Done means shx reports the self-copy error instead of creating nested prod directories.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.