-
Notifications
You must be signed in to change notification settings - Fork 744
Inconsistent behaviour of cp command with directories. #44
Description
cp command behaves differently from their shell parent.
Suppose, we have the following structure:
- dir1/
- lib/
- main.js
- lib/
Or in shelljs code:
require('shelljs/global')
mkdir('dir1')
mkdir('dir1/lib')
echo('123').to('dir1/lib/main.js');
All these commands fail on my system:
cp('-r', 'dir1/*', 'dir2/')
shell.js: internal error
Error: ENOENT, no such file or directory 'dir2//lib'
at Object.fs.mkdirSync (fs.js:483:18)
at code/node_modules/shelljs/shell.js:306:14
at Array.forEach (native)
at _cp (code/node_modules/shelljs/shell.js:288:11)
at code/node_modules/shelljs/shell.js:1103:23
at repl:1:2
at REPLServer.self.eval (repl.js:111:21)
at Interface. (repl.js:250:12)
at Interface.EventEmitter.emit (events.js:93:17)
at Interface._onLine (readline.js:199:10)cp('-r', 'dir1', 'dir2');
shell.js: internal error
Error: ENOENT, no such file or directory 'dir2/dir1'
at Object.fs.mkdirSync (fs.js:483:18)
at code/node_modules/shelljs/shell.js:306:14
at Array.forEach (native)
at _cp (code/node_modules/shelljs/shell.js:288:11)
at code/node_modules/shelljs/shell.js:1103:23
at repl:1:1
at REPLServer.self.eval (repl.js:111:21)
at rli.on.self.bufferedCmd (repl.js:260:20)
at REPLServer.self.eval (repl.js:118:5)
at Interface. (repl.js:250:12)cp('-r', 'dir1/', 'dir2/')
shell.js: internal error
Error: ENOENT, no such file or directory 'dir2//lib'
at Object.fs.mkdirSync (fs.js:483:18)
at code/node_modules/shelljs/shell.js:306:14
at Array.forEach (native)
at _cp (code/node_modules/shelljs/shell.js:288:11)
at code/node_modules/shelljs/shell.js:1103:23
at repl:1:2
at REPLServer.self.eval (repl.js:111:21)
at Interface. (repl.js:250:12)
at Interface.EventEmitter.emit (events.js:93:17)
at Interface._onLine (readline.js:199:10)cp('-R', 'dir1/', 'dir2');
shell.js: internal error
Error: ENOENT, no such file or directory 'dir2/lib'
at Object.fs.mkdirSync (fs.js:483:18)
at code/node_modules/shelljs/shell.js:306:14
at Array.forEach (native)
at _cp (code/node_modules/shelljs/shell.js:288:11)
at code/node_modules/shelljs/shell.js:1103:23
at repl:1:1
at REPLServer.self.eval (repl.js:111:21)
at rli.on.self.bufferedCmd (repl.js:260:20)
at REPLServer.self.eval (repl.js:118:5)
at Interface. (repl.js:250:12)
but all this calls successfully run if I've created the dir2 directory previously.
cp from bash always creates target directory (only one level) if necessary. So all these calls finish successfully.