[Toybox] [landley/toybox] Add ln -r (#145)

scsijon scsijon at lamiaworks.com.au
Sat Oct 26 14:06:43 PDT 2019



On 27/10/19 05:17, toybox-request at lists.landley.net wrote:
> 
> Message: 4
> Date: Fri, 25 Oct 2019 18:29:26 -0500
> From: Rob Landley <rob at landley.net>
> To: toybox <toybox at lists.landley.net>
> Subject: Re: [Toybox] [landley/toybox] Add ln -r (#145)
> Message-ID: <5f6e3f93-c890-f66e-610a-f38f018b87c3 at landley.net>
> Content-Type: text/plain; charset=utf-8
> 
> On 10/21/19 10:33 PM, E5ten wrote:
>> @E5ten <https://github.com/E5ten> pushed 1 commit.
>>
>>    * 1ecba70
>>      <https://github.com/landley/toybox/commit/1ecba701ff655a64741f47cd443b4fb3184edde1>
>>      ln -r: replace getdirname with dirname
> 
> Ok, cycling back to this (where "this" is
> https://github.com/landley/toybox/pull/145 but you just have to kind of know
> that rather than following links in the email notification)...
> 
> What does ln -r _do_ exactly? Some examples would be nice, but you didn't
> include any new tests in tests/ln.test to see if it's passing? (And the man page
> isn't particularly useful, "create symbolic links relative to link location"
> could be a couple things.)
> 
Funny thing, the only place I can find a inline doc for ln -r is in gnu at
https://www.gnu.org/software/coreutils/manual/html_node/ln-invocation.html#ln-invocation, 
it's not listed online against the ~bsd's, linux.die, wikapedia, or even 
macos. There's an example there, but it doesn't attempt to use r by 
itself but mixes it with s and v as ln -srv . ther's a test there too.


> If the syntax is the same as "cp -s" then possibly it should use the cp -s
> plumbing? (Which might involve factoring it out into lib/ or merging ln into
> cp?) Let's try experimenting with the debian version...
> 
> $ ln -r toys/*/ln.c www/murgle
> ln: cannot do --relative without --symbolic
> 
> *facepalm* You can have an option imply another option, you know.
> 
> $ ln -sr toys/*/ln.c www/murgle
> $ ls -l www/murgle
> lrwxrwxrwx 1 landley landley 18 Oct 25 18:09 www/murgle -> ../toys/posix/ln.c
> 
> Ok. Is that the same as cp -s?
> 
> $ cp -s toys/*/ln.c www/murgle2
> cp: www/murgle2: can make relative symbolic links only in current directory
> 
> Ahem: is that the same as _toybox_ cp -s?
> 
> $ toybox cp -s toys/*/ln.c www/murgle2
> $ ls -l www/murgle*
> lrwxrwxrwx 1 landley landley 18 Oct 25 18:09 www/murgle -> ../toys/posix/ln.c
> lrwxrwxrwx 1 landley landley 15 Oct 25 18:09 www/murgle2 -> toys/posix/ln.c
> 
> Answer: no, but I think that's a bug in toybox cp -s.
> 
> Next question:
> 
> $ ln -s . circular
> $ ln -sr circular/todo.txt www/murgle3
> $ ls -l www/murgle3
> lrwxrwxrwx 1 landley landley 11 Oct 25 18:19 www/murgle3 -> ../todo.txt
> $ ln -sr www/oldnews.html circular/murgle4
> $ ls -l murgle4
> lrwxrwxrwx 1 landley landley 16 Oct 25 18:21 murgle4 -> www/oldnews.html
> 
> Yup, it's creating a relative path between the two abspaths. (Which it would
> kind of have to for the link to _work_.)
> 
> I think I need a new lib function to do this, and I should change cp -s to use
> it too. And I need more cp tests because the above cp -s made a broken symlink...
> 
> Rob
> 



More information about the Toybox mailing list