[Toybox] [PATCH] realpath/readlink: fixes and improvements.

enh enh at google.com
Fri Jun 19 11:13:05 PDT 2020


The main feature here (and motivation for this change) is adding
--relative-to to realpath for 4.19 kernel builds, but I've also added -e,
-m, -q, and -z too.

I've added tests for realpath (starting from a modified version of the
readlink tests, but also with realpath-specific extensions).

I've changed xabspath() to handle ENOTDIR for the "file/dir" case, which
we previously got wrong. The tests were wrong too, but with this patch
they pass for both toybox and coreutils 8.30.

One interesting change here is that -q doesn't mean what you'd expect it
to mean. coreutils' readlink --help output doesn't say anything for -q
(a joke?) but their realpath --help is accurate when it says "suppress
most error messages". That is: -q does *not* suppress regular output as
it does in so many other commands, just ["most"] errors. Since we don't
output any of those errors anyway, -q is a no-op for toybox (at least
unless we start being more noisy on failure).

Bug: https://issuetracker.google.com/157287684
---
 lib/xwrap.c           |  2 +-
 tests/readlink.test   |  8 ++--
 tests/realpath.test   | 63 ++++++++++++++++++++++++++++
 toys/other/readlink.c | 96 ++++++++++++++++++++++++++++++++++---------
 4 files changed, 146 insertions(+), 23 deletions(-)
 create mode 100755 tests/realpath.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-realpath-readlink-fixes-and-improvements.patch
Type: text/x-patch
Size: 10209 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20200619/2bf9c908/attachment-0002.bin>


More information about the Toybox mailing list