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

enh enh at google.com
Mon Nov 4 10:50:59 PST 2019


On Mon, Nov 4, 2019 at 6:10 AM Andrew Ilijic <ilijic.andrew at gmail.com> wrote:
>
> Just a quick update and some questions. I have `realpath` implemented
> in the `readlink` file. I am using the `readlink` tests as a rough
> template and working on implementing them and getting them to pass for
> `realpath`.
>
> http://man7.org/linux/man-pages/man1/realpath.1.html
> http://man7.org/linux/man-pages/man1/readlink.1.html
> I saw that options `-v` and `-z` were not implemented for `readlink`.
> Do we want those options implemented? What about `-z` for `realpath`?
> I noticed that only the long-form argument `--canonicalize` is turned
> on. Do you want me to turn on the others?

i'm generally pro long-options because i think they're easier to
remember. rob is generally anti; in particular he really doesn't like
cases where there's a long option without any corresponding short
option. (though i think that's a good idea for rarely-used options
because there are only 2*26 short options -- and far fewer _good_ ones
-- and again, rarely used options are the ones where the more
memorable long names are more helpful.)

the compromise we seem to have settled on is "is this long option used
in the wild?". so we're not adding them "just because", but as soon as
we find real scripts, we add them.

checking my AOSP notes, --no-symlinks and --relative-to are both used,
but i don't currently know of any other long options AOSP needs.

> ~Andrew
>
> On Sun, Oct 27, 2019 at 6:33 PM Rob Landley <rob at landley.net> wrote:
> >
> > On 10/26/19 1:17 PM, enh wrote:
> > >> P.S. And I need an xabspath(file, -2) variant that resolves everything except
> > >> the last path component,
> >
> > Which is in now, I should do macros for the second constant ala DIRTREE and
> > MKPATHAT and HR _SPACE and such.
> >
> > >> because that's what tar wants for this directory
> > >> replaces symlink thing. I need to resolve before calling unlink() so you can't
> > >> trick tar into deleting random stuff by following a symlink...
> > >
> > > (see also the current realpath(1), which doesn't support -s or
> > > --relative-to, which i think will need realpath.c to switch to a
> > > home-grown implementation instead of realpath(3).)
> >
> > I think the plumbing is there now?
> >
> > It actually sounds like realpath might get merged into readlink.c because:
> >
> >     Options for producing canonical paths (all symlinks/./.. resolved):
> >
> >     -e  Canonical path to existing entry (fail if missing)
> >     -f  Full path (fail if directory missing)
> >     -m  Ignore missing entries, show where it would be
> >     -n  No trailing newline
> >     -q  Quiet (no output, just error code)
> >
> > Is already doing most of it? (That's the one I use...)
> >
> > Let's see, -e -m and -q are the same. But realpath has -L -s and -z which are
> > new, and -P which is a NOP? (Well, [-LP] maybe?) And then --relative-to I just
> > added plumbing for, and --relative-base needs to be implemented.
> >
> > Hey Andrew: you wanted todo items,here's a fresh one if it looks interesting. :)
> >
> > Rob



More information about the Toybox mailing list