Patch to add "-r" option (create relative symlinks) to coreutils/ln

Tito farmatito at tiscali.it
Sat Jun 18 19:41:08 UTC 2016



On 06/18/2016 05:24 PM, Ross Thomas wrote:
> I recently had a need for the "-r" option to ln while using Busybox, and
> it turned out to be easy enough to add, so here's a patch against v1.24.2.
> 
> This is the first time I've poked at the BB source so it's possible I
> overlooked something helpful in libbb, or am not using approved style,
> or whatever. Suggestions welcome!
> 
> Thanks,
> 
> R
> 

Hi,
i think you could use something like:

	opt_complementary = "-1:r?s"; /* min one arg */

so to raise an error if -r is used without -s like real ln does:


ln: cannot do --relative without --symbolic

from libb/getopt32

 "a?b"  A "?" between an option and a group of options means that
        at least one of them is required to occur if the first option
        occurs in preceding command line arguments.

        For example from "id" applet:

        // Don't allow -n -r -rn -ug -rug -nug -rnug
        opt_complementary = "r?ug:n?ug:u--g:g--u";
        flags = getopt32(argv, "rnug");

        This example allowed only:
        $ id; id -u; id -g; id -ru; id -nu; id -rg; id -ng; id -rnu; id -rng

This is just a untested hint.

Ciao,
Tito


More information about the busybox mailing list