shelljs / shx

Portable Shell Commands for Node
MIT License
1.73k stars 45 forks source link

shx cp -r Creates nested recursive directories #209

Open tvomacka opened 1 year ago

tvomacka commented 1 year ago

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"

nfischer commented 1 year ago

Look similar to (but not exactly the same as) https://github.com/shelljs/shelljs/issues/1092. Should probably fix both at the same time.