Since someone made a github issue requesting ip, I took a closer look at ip.c

The first thing I noticed is that "ip" with no args returns usage text instead
of help text (Like sed did before that got fixed some time months ago) or
defaulting to "ip addr" (Which is what ip usually does). Not a big issue, but
still it'd be nice to have that since non-toybox ip does "ip addr" on no args.

The second issue is that "make ipaddr" breaks because of a compiler error in
scripts/install.c when trying to include generated/newtoys.h for "help_data".
Which is weird, but it's due to multiple OLDTOYS using the same USE_ macro.

They need their own USE_ macros and config symbols like {e,f}grep if they should
be build-able as individual sub-commands. (Unlike {e,f}grep, they should default
to "n" so they don't get included on a build of ip)

Attached is a patch which fixes "make ipsubcmd"

-   Oliver Webb <[email protected]>
From fe1c429896f6b631a62a497911ddede368988b67 Mon Sep 17 00:00:00 2001
From: Oliver Webb <[email protected]>
Date: Mon, 8 Apr 2024 22:46:08 -0500
Subject: [PATCH] ip.c: Give subcommands their own config symbols so they don't
 break on "make ipsubcmd"

---
 toys/pending/ip.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/toys/pending/ip.c b/toys/pending/ip.c
index 52deec4e..4c8d70a9 100644
--- a/toys/pending/ip.c
+++ b/toys/pending/ip.c
@@ -8,11 +8,11 @@
  * No Standard.
  *
 USE_IP(NEWTOY(ip, NULL, TOYFLAG_SBIN))
-USE_IP(OLDTOY(ipaddr, ip, TOYFLAG_SBIN))
-USE_IP(OLDTOY(iplink, ip, TOYFLAG_SBIN))
-USE_IP(OLDTOY(iproute, ip, TOYFLAG_SBIN))
-USE_IP(OLDTOY(iprule, ip, TOYFLAG_SBIN))
-USE_IP(OLDTOY(iptunnel, ip, TOYFLAG_SBIN))
+USE_IPADDR(OLDTOY(ipaddr, ip, TOYFLAG_SBIN))
+USE_IPLINK(OLDTOY(iplink, ip, TOYFLAG_SBIN))
+USE_IPROUTE(OLDTOY(iproute, ip, TOYFLAG_SBIN))
+USE_IPRULE(OLDTOY(iprule, ip, TOYFLAG_SBIN))
+USE_IPTUNNEL(OLDTOY(iptunnel, ip, TOYFLAG_SBIN))
 
 config IP
   bool "ip"
@@ -24,6 +24,31 @@ config IP
 
     where OBJECT := {address | link | route | rule | tunnel}
     OPTIONS := { -f[amily] { inet | inet6 | link } | -o[neline] }
+
+config IPADDR
+  bool
+  default n
+  depends on IP
+
+config IPLINK
+  bool
+  default n
+  depends on IP
+
+config IPROUTE
+  bool
+  default n
+  depends on IP
+
+config IPRULE
+  bool
+  default n
+  depends on IP
+
+config IPTUNNEL
+  bool
+  default n
+  depends on IP
 */
 #define FOR_ip
 #include "toys.h"
-- 
2.44.0

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to