Add config option for --help support in all commands.
diff --git a/main.c b/main.c
index b0b2bb2..ee16e64 100644
--- a/main.c
+++ b/main.c
@@ -84,6 +84,12 @@
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 @@
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 @@
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();