readlink/realpath -m in busybox
Eli Schwartz
eschwartz at archlinux.org
Sun Mar 22 01:26:48 UTC 2020
On 3/21/20 5:12 AM, Johannes Schauer wrote:
> Hi,
>
> is there existing code that works with busybox and replaces "readlink -m" or
> "realpath -m" from coreutils?
>
> Resources I found online either show solution for "readlink -f" only, when
> neither readlink nor realpath exists, when Perl is available or when bash is
> available.
>
> Specifically I want to replace the "readlink -m" invocation here [1] by
> something that works with busybox.
>
> Thanks!
>
> cheers, josch
>
> [1] https://sources.debian.org/src/glibc/2.30-2/debian/debhelper.in/libc.preinst/#L226
I can't think of one, but you could implement it in pure shell by
checking the return code of readlink without options (it will fail if
the file is not a symlink), and walk the path to find the first
directory that exists in order to support -m. This would be pretty
compatible with any readlink implementation, including ones without -f.
Probably the nicest option would be to submit a patch that implements
readlink -m for busybox, so that it just works. It's a nice, useful
option to have, so why not add it?
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1597 bytes
Desc: OpenPGP digital signature
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20200321/4fdbabd0/attachment.asc>
More information about the busybox
mailing list