aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-08-13 17:50:54 -0500
committerRob Landley <rob@landley.net>2016-08-13 17:50:54 -0500
commite98089ab9a4b52664e8baf1168af0ad0b32398ba (patch)
tree927101b65a18c955a6d41fcad707954c04496836
parentbc1ccaccb5b7ec71775a5eb7e529bb93811956ce (diff)
downloadtoybox-e98089ab9a4b52664e8baf1168af0ad0b32398ba.tar.gz
Add TOYFLAG_NOHELP to disable --help processing for individual commands,
apply it to "true" and "false".
-rw-r--r--lib/toyflags.h3
-rw-r--r--main.c4
-rw-r--r--toys/posix/false.c2
-rw-r--r--toys/posix/true.c4
4 files changed, 9 insertions, 4 deletions
diff --git a/lib/toyflags.h b/lib/toyflags.h
index 963295cc..e809901d 100644
--- a/lib/toyflags.h
+++ b/lib/toyflags.h
@@ -25,3 +25,6 @@
// Call setlocale to listen to environment variables.
// This invalidates sprintf("%.*s", size, string) as a valid length constraint.
#define TOYFLAG_LOCALE (1<<8)
+
+// Suppress default --help processing
+#define TOYFLAG_NOHELP (1<<9)
diff --git a/main.c b/main.c
index 31e51b17..c0c1b824 100644
--- a/main.c
+++ b/main.c
@@ -75,7 +75,9 @@ static void toy_singleinit(struct toy_list *which, char *argv[])
if (CFG_TOYBOX_I18N) setlocale(LC_ALL, "C"+!!(which->flags & TOYFLAG_LOCALE));
- if (CFG_TOYBOX_HELP_DASHDASH && argv[1] && !strcmp(argv[1], "--help")) {
+ if (CFG_TOYBOX_HELP_DASHDASH && !(which->flags & TOYFLAG_NOHELP)
+ && argv[1] && !strcmp(argv[1], "--help"))
+ {
if (CFG_TOYBOX && toys.which == toy_list && toys.argv[2])
if (!(toys.which = toy_find(toys.argv[2]))) return;
show_help(stdout);
diff --git a/toys/posix/false.c b/toys/posix/false.c
index 73458bea..0853b010 100644
--- a/toys/posix/false.c
+++ b/toys/posix/false.c
@@ -4,7 +4,7 @@
*
* See http://opengroup.org/onlinepubs/9699919799/utilities/false.html
-USE_FALSE(NEWTOY(false, NULL, TOYFLAG_BIN))
+USE_FALSE(NEWTOY(false, NULL, TOYFLAG_BIN|TOYFLAG_NOHELP))
config FALSE
bool "false"
diff --git a/toys/posix/true.c b/toys/posix/true.c
index 0fbb1786..2543b821 100644
--- a/toys/posix/true.c
+++ b/toys/posix/true.c
@@ -4,8 +4,8 @@
*
* See http://opengroup.org/onlinepubs/9699919799/utilities/true.html
-USE_TRUE(NEWTOY(true, NULL, TOYFLAG_BIN))
-USE_TRUE(OLDTOY(:, true, TOYFLAG_NOFORK))
+USE_TRUE(NEWTOY(true, NULL, TOYFLAG_BIN|TOYFLAG_NOHELP))
+USE_TRUE(OLDTOY(:, true, TOYFLAG_NOFORK|TOYFLAG_NOHELP))
config TRUE
bool "true"