sahib / rmlint

Extremely fast tool to remove duplicates and other lint from your filesystem
http://rmlint.rtfd.org
GNU General Public License v3.0
1.91k stars 132 forks source link

Add relative symlinking to the symlink process #513

Open Suika opened 3 years ago

Suika commented 3 years ago

I noticed that rmlint only does absolute links due to the way the files are passed to the link executable. It would be nice to have the ability to set a flag, that will create relative links. ie. ln -s -r. https://github.com/sahib/rmlint/blob/master/lib/formats/sh.sh#L176 If that option is set, ln will not create an absolute path and will find the shortest way to the target.

I think I saw an issue that fixed the lookup of the symlinks that contain relative paths, so this should be safe. Well, I can always edit the generated rmlint.sh and it will work due to the proper way rmlint references and uses the commands.

SeeSpotRun commented 3 years ago

You can do this now via:

$ rmlint -o sh -c sh:cmd='echo "symlinking to original $2" && rm -rf "$1" && ln -s -r  "$2" "$1"'

Or we could add an option like rmlint -c sh:symlink -c sh:relative

Suika commented 3 years ago

Pretty sure -c sh:relative is less prone to problems and easer to comprehend than the other thing you wrote out. Mess sh:cmd= up and things could go wrong.