Am 21.03.2012 04:27, schrieb Pádraig Brady: > On 02/24/2012 12:12 AM, Pádraig Brady wrote: >> On 02/23/2012 09:28 PM, Eric Blake wrote: >>> On 02/23/2012 12:50 PM, [email protected] wrote: >>>> From: Harald Hoyer <[email protected]> >>>> >>>> With the "--relative --symbolic" options, ln computes the relative >>>> symbolic link for the user. >>>> >>>> So, ln works just as cp, but creates relative symbolic links instead >>>> of copying the file. >>> >>> In general, I like the idea. I will point out that we now have realpath >>> that also can compute relative locations to an arbitrary starting point, >>> so we probably ought to share the code between the two programs rather >>> than rewriting it. >> >> I like the functionality too. >> As Eric points out, the new `realpath` util has the >> relative path generation logic in it, which should be reused. >> To demonstrate the equivalence you could implement this >> functionality modulo option handling using `realpath` like: >> >> ln--relative() { >> target="$1"; link_name="$2" >> rtarget="$(realpath -m "$target" --relative-to "$(dirname "$link_name")")" >> ln -s -v "$rtarget" "$link_name" >> } >> >> Now given the simplicity of the above, there is the argument >> that new options within ln are not needed. We've discussed >> on and off the idea of a contrib/ folder in coreutils to >> provide generally useful but higher level commands like this. >> Worth considering at least. > > Attached is a quick PoC refactoring to use existing code. > > cheers, > Pádraig.
Worksforme :-) Go for it!
