aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-08-21 03:03:47 -0500
committerRob Landley <rob@landley.net>2013-08-21 03:03:47 -0500
commit5f80533836c60a167f69b71624fad5c494057ee2 (patch)
treee148a77b51be5625cb70238854e4e94145ddef25 /main.c
parent57da5bfa162f7c6cd6f165d0cdbedecda4d7d1e0 (diff)
downloadtoybox-5f80533836c60a167f69b71624fad5c494057ee2.tar.gz
Fix --help option to multiplexer.
Diffstat (limited to 'main.c')
-rw-r--r--main.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/main.c b/main.c
index 20ec5b10..8218b0fd 100644
--- a/main.c
+++ b/main.c
@@ -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]);
}