rushsteve1/trash-d

cannot trash broken soft links

ninedotnine opened this issue · 3 comments

» touch file 
» ln -s file link
» ls -l
-rw-r--r-- 1   0 dan dan 15 mai 23:39 file
lrwxrwxrwx 1   4 dan dan 15 mai 23:39 link -> file
» trash file  
» ls -l
lrwxrwxrwx 1   4 dan dan 15 mai 23:39 link -> file
» trash link
trash: link: No such file or directory
» ls -l
lrwxrwxrwx 1   4 dan dan 15 mai 23:39 link -> file

Broken links must be deleted with rm instead.

It seems that trash-d is trying to follow the symlink and failing since it's broken.
I've been debating what the best way to fix this is. I think I might go the route that symlinks should not be followed at all.

For comparison, rm never follows symlinks, except for directories that are suffixed with a /:

» mkdir d
» ln -s d link
» tree
.
├── d
└── link -> d
» rm link/
rm: cannot remove 'link/': Is a directory
» rm link
» tree
.
└── d
»

This should now be fixed and will make it into release 17. There's now some test cases for this too, but let me know if you still have issues.