Commit 5a9d2b6e0 (libbb: make '--help' handling more consistent)
broke the command "[ --help ]".  This should check that the string
is non-empty, not display help.

function                                             old     new   delta
show_usage_if_dash_dash_help                          69      74      +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 5/0)                 Total: 5 bytes

Signed-off-by: Ron Yorston <r...@pobox.com>
Reported-by: Harald van Dijk <har...@gigawatt.nl>
---
 applets/applet_tables.c | 4 ++++
 libbb/appletlib.c       | 8 +++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/applets/applet_tables.c b/applets/applet_tables.c
index 66ef7e4ac..923cb2a22 100644
--- a/applets/applet_tables.c
+++ b/applets/applet_tables.c
@@ -147,6 +147,10 @@ int main(int argc, char **argv)
        for (i = 0; i < NUM_APPLETS; i++) {
                if (str_isalnum_(applets[i].name))
                        printf("#define APPLET_NO_%s %d\n", applets[i].name, i);
+               else if (strcmp(applets[i].name, "[") == 0)
+                       printf("#define APPLET_NO_test1 %d\n", i);
+               else if (strcmp(applets[i].name, "[[") == 0)
+                       printf("#define APPLET_NO_test2 %d\n", i);
        }
        printf("\n");
 
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 9b9d7dbd6..a9901aa72 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -923,12 +923,18 @@ void FAST_FUNC show_usage_if_dash_dash_help(int 
applet_no, char **argv)
        /* Special case. POSIX says "test --help"
         * should be no different from e.g. "test --foo".
         * Thus for "test", we skip --help check.
-        * "true", "false", "echo" are also special.
+        * "[", "[[", "true", "false", "echo" are also special.
         */
        if (1
 #  if defined APPLET_NO_test
         && applet_no != APPLET_NO_test
 #  endif
+#  if defined APPLET_NO_test1
+        && applet_no != APPLET_NO_test1
+#  endif
+#  if defined APPLET_NO_test2
+        && applet_no != APPLET_NO_test2
+#  endif
 #  if defined APPLET_NO_true
         && applet_no != APPLET_NO_true
 #  endif
-- 
2.37.2

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to