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

Rob Landley rob at landley.net
Fri Oct 25 16:29:26 PDT 2019


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.)

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