diff options
author | Rob Landley <rob@landley.net> | 2013-08-21 03:03:47 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2013-08-21 03:03:47 -0500 |
commit | 5f80533836c60a167f69b71624fad5c494057ee2 (patch) | |
tree | e148a77b51be5625cb70238854e4e94145ddef25 /main.c | |
parent | 57da5bfa162f7c6cd6f165d0cdbedecda4d7d1e0 (diff) | |
download | toybox-5f80533836c60a167f69b71624fad5c494057ee2.tar.gz |
Fix --help option to multiplexer.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 16 |
1 files changed, 5 insertions, 11 deletions
@@ -67,6 +67,8 @@ static void toy_singleinit(struct toy_list *which, char *argv[]) toys.argv = argv; if (CFG_TOYBOX_HELP_DASHDASH && argv[1] && !strcmp(argv[1], "--help")) { + if (toys.which == toy_list && toys.argv[2]) + if (!(toys.which = toy_find(toys.argv[2]))) return; show_help(); xexit(); } @@ -114,7 +116,7 @@ void toy_exec(char *argv[]) if (!(which = toy_find(argv[0]))) return; toy_init(which, argv); - toys.which->toy_main(); + if (toys.which) toys.which->toy_main(); if (fflush(NULL) || ferror(stdout)) perror_exit("write"); xexit(); } @@ -129,16 +131,8 @@ void toybox_main(void) toys.which = toy_list; if (toys.argv[1]) { - 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(); - return; - } - } else { - toy_exec(toys.argv+1); - if (toys.argv[1][0] == '-') goto list; - } + toy_exec(toys.argv+1); + if (toys.argv[1][0] == '-') goto list; error_exit("Unknown command %s",toys.argv[1]); } |