diff options
author | Rob Landley <rob@landley.net> | 2013-06-30 15:58:24 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2013-06-30 15:58:24 -0500 |
commit | 953722e3826c779f261a4c8a3649e36b1333a86f (patch) | |
tree | 48ba5f258b0a996b3a6a40895e3c465a0ff6487a | |
parent | 302d9d3e5138e950487dd22ab9e8b1d32a67456c (diff) | |
download | toybox-953722e3826c779f261a4c8a3649e36b1333a86f.tar.gz |
Add config option for --help support in all commands.
-rw-r--r-- | Config.in | 8 | ||||
-rw-r--r-- | main.c | 10 |
2 files changed, 16 insertions, 2 deletions
@@ -41,6 +41,14 @@ config TOYBOX_HELP help Include help text for each command. +config TOYBOX_HELP_DASHDASH + bool "--help" + default y + depends on TOYBOX_HELP + help + Support --help argument in all commands, even ones with a NULL + optstring. Produces the same output as "help command". + config TOYBOX_I18N bool "Internationalization support" default y @@ -84,6 +84,12 @@ void toy_init(struct toy_list *which, char *argv[]) toys.which = which; toys.argv = argv; + + if (CFG_TOYBOX_HELP_DASHDASH && argv[1] && !strcmp(argv[1], "--help")) { + show_help(); + xexit(); + } + if (NEED_OPTIONS && which->options) get_optflags(); else { toys.optargs = argv+1; @@ -103,7 +109,7 @@ void toy_exec(char *argv[]) toy_init(which, argv); toys.which->toy_main(); if (fflush(NULL) || ferror(stdout)) perror_exit("write"); - exit(toys.exitval); + xexit(); } // Multiplexer command, first argument is command to run, rest are args to that. @@ -116,7 +122,7 @@ void toybox_main(void) toys.which = toy_list; if (toys.argv[1]) { - if (CFG_TOYBOX_HELP && !strcmp(toys.argv[1], "--help")) { + if (CFG_TOYBOX_HELP_DASHDASH && !strcmp(toys.argv[1], "--help")) { if (toys.argv[2]) toys.which = toy_find(toys.argv[2]); if (toys.which) { show_help(); |