-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
Description
Copying files as symbolic links to a new (sub-)directory would require constructing a relative path from the new location to the old, e.g. starting with ../.
Trying to do so would necessarily be very fragile. GNU cp even refuses to attempt it. However, uutils currently does it, very badly, resulting in completely broken links and exit code 0.
$ mkdir newdir
$ cp -vs README.md newdir/ # GNU refuses to create broken symbolic links
'README.md' -> 'newdir/README.md'
cp: newdir/README.md: can make relative symbolic links only in current directory
[$? = 1]
$ ls newdir/ # It's empty
$ cargo run -q cp -vs README.md newdir/ # uutils returns "success"
'README.md' -> 'newdir/README.md'
$ ls newdir/ # And creates something
README.md
$ readlink newdir/README.md # It creates a self-link
README.md
$ less newdir/README.md
newdir/README.md: Too many levels of symbolic links
[$? = 1]Discovered while reviewing #6380.