Required by the new `ln -t` test if it's to pass on an all-toybox
system :-)
---
toys/other/readlink.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
From 5f9a89f3f80abf2f443660c39bcbade68496c9ac Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Mon, 30 Sep 2019 17:15:40 -0700
Subject: [PATCH] readlink: support multiple arguments.
Required by the new `ln -t` test if it's to pass on an all-toybox
system :-)
---
toys/other/readlink.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/toys/other/readlink.c b/toys/other/readlink.c
index beef92b0..eb63d7f4 100644
--- a/toys/other/readlink.c
+++ b/toys/other/readlink.c
@@ -8,7 +8,7 @@ config READLINK
bool "readlink"
default y
help
- usage: readlink FILE
+ usage: readlink FILE...
With no options, show what symlink points to, return error if not symlink.
@@ -26,17 +26,18 @@ config READLINK
void readlink_main(void)
{
- char *s;
-
- // Calculating full canonical path?
- // Take advantage of flag positions to calculate m = -1, f = 0, e = 1
- if (toys.optflags & (FLAG_f|FLAG_e|FLAG_m))
- s = xabspath(*toys.optargs, (toys.optflags&(FLAG_f|FLAG_e))-1);
- else s = xreadlink(*toys.optargs);
-
- if (s) {
- if (!(toys.optflags & FLAG_q))
- xprintf((toys.optflags & FLAG_n) ? "%s" : "%s\n", s);
- if (CFG_TOYBOX_FREE) free(s);
- } else toys.exitval = 1;
+ char **arg, *s;
+
+ for (arg = toys.optargs; *arg; arg++) {
+ // Calculating full canonical path?
+ // Take advantage of flag positions to calculate m = -1, f = 0, e = 1
+ if (toys.optflags & (FLAG_f|FLAG_e|FLAG_m))
+ s = xabspath(*arg, (toys.optflags&(FLAG_f|FLAG_e))-1);
+ else s = xreadlink(*arg);
+
+ if (s) {
+ if (!FLAG(q)) xprintf(FLAG(n) ? "%s" : "%s\n", s);
+ if (CFG_TOYBOX_FREE) free(s);
+ } else toys.exitval = 1;
+ }
}
--
2.23.0.444.g18eeb5a265-goog
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net