[Toybox] [PATCH] main.c: don't assume anything starting with -- is --long.

enh enh at google.com
Wed Oct 17 15:43:52 PDT 2018


Test: `./toybox --oops` correctly shows help now
---
 main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/main.c b/main.c
index 6f8490f..46f571e 100644
--- a/main.c
+++ b/main.c
@@ -202,9 +202,11 @@ void toybox_main(void)
     int fl = toy_list[i].flags;
     if (fl & TOYMASK_LOCATION) {
       if (toys.argv[1]) {
-        int j;
-        for (j=0; toy_paths[j]; j++)
-          if (fl & (1<<j)) len += printf("%s", toy_paths[j]);
+        if (!strcmp(toys.argv[1], "--long")) {
+          int j;
+          for (j=0; toy_paths[j]; j++)
+            if (fl & (1<<j)) len += printf("%s", toy_paths[j]);
+        } else help_exit(0);
       }
       len += printf("%s",toy_list[i].name);
       if (++len > 65) len = 0;
-- 
2.19.1.331.ge82ca0e54c-goog
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-main.c-don-t-assume-anything-starting-with-is-long.patch
Type: text/x-patch
Size: 1007 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20181017/5f2a1357/attachment-0002.bin>


More information about the Toybox mailing list