Skip to content

cp -L: Incorrect behavior for symlinks to regular files #407

@nfischer

Description

@nfischer

#232 is an awesome contribution! I've been testing it out, and really like it. Here's one bug I noticed on my Ubuntu box, however, running Node v5.

cp('-RL', src, dest) doesn't work quite right. Here's some output I got that wasn't quite expected. The symlinks are both symlinks to file.txt (a regular file), but they're being treated like directories by the copy.

$ ls -RCF sub/ #notice that foo.lnk and sym.lnk are links (in this case, to file.txt)
sub/:
file.txt  foo.lnk@  sym.lnk@

$ cat script.js
require('shelljs/global');
cp('-rL', 'sub/', 'new/');

$ rm -rf new/

$ node script.js

$ ls -RCF new/ # notice that foo.lnk is a directory, not a regular file
new/:
file.txt  foo.lnk/

new/foo.lnk:

Also, I noticed the tests focus on the maxdepth and cycle detection, but it might be good to throw in some tests to just for the very basic cp -L and cp -LR behavior.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions