[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] ln: add the --relative option

From: Harald Hoyer
Subject: Re: [PATCH v2] ln: add the --relative option
Date: Wed, 21 Mar 2012 13:00:14 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120316 Thunderbird/11.0

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, address@hidden wrote:
>>>> From: Harald Hoyer <address@hidden>
>>>> 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!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]