echo: special case "echo --help": it should not show help text
While at it, fix "busybox --help echo" and other special applets to still print the help text. function old new delta run_applet_and_exit 732 761 +29 show_usage_if_dash_dash_help 70 78 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 37/0) Total: 37 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
f25d254dfd
commit
f26e5634b1
@ -263,9 +263,14 @@ void lbb_prepare(const char *applet
|
|||||||
&& strcmp(argv[1], "--help") == 0
|
&& strcmp(argv[1], "--help") == 0
|
||||||
&& !is_prefixed_with(applet, "busybox")
|
&& !is_prefixed_with(applet, "busybox")
|
||||||
) {
|
) {
|
||||||
/* Special case. POSIX says "test --help"
|
/* Special cases. POSIX says "test --help"
|
||||||
* should be no different from e.g. "test --foo". */
|
* should be no different from e.g. "test --foo".
|
||||||
if (!ENABLE_TEST || strcmp(applet_name, "test") != 0)
|
*/
|
||||||
|
if (!(ENABLE_TEST && strcmp(applet_name, "test") == 0)
|
||||||
|
&& !(ENABLE_TRUE && strcmp(applet_name, "true") == 0)
|
||||||
|
&& !(ENABLE_FALSE && strcmp(applet_name, "false") == 0)
|
||||||
|
&& !(ENABLE_ECHO && strcmp(applet_name, "echo") == 0)
|
||||||
|
)
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -891,15 +896,21 @@ int busybox_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (!argv[2])
|
if (!argv[2])
|
||||||
goto help;
|
goto help;
|
||||||
/* convert to "<applet> --help" */
|
/* convert to "<applet> --help" */
|
||||||
argv[0] = argv[2];
|
applet_name = argv[0] = argv[2];
|
||||||
argv[2] = NULL;
|
argv[2] = NULL;
|
||||||
|
if (find_applet_by_name(applet_name) >= 0) {
|
||||||
|
/* Make "--help foo" exit with 0: */
|
||||||
|
xfunc_error_retval = 0;
|
||||||
|
bb_show_usage();
|
||||||
|
} /* else: unknown applet, fall through (causes "applet not found" later) */
|
||||||
} else {
|
} else {
|
||||||
/* "busybox <applet> arg1 arg2 ..." */
|
/* "busybox <applet> arg1 arg2 ..." */
|
||||||
argv++;
|
argv++;
|
||||||
|
/* We support "busybox /a/path/to/applet args..." too. Allows for
|
||||||
|
* "#!/bin/busybox"-style wrappers
|
||||||
|
*/
|
||||||
|
applet_name = bb_get_last_path_component_nostrip(argv[0]);
|
||||||
}
|
}
|
||||||
/* We support "busybox /a/path/to/applet args..." too. Allows for
|
|
||||||
* "#!/bin/busybox"-style wrappers */
|
|
||||||
applet_name = bb_get_last_path_component_nostrip(argv[0]);
|
|
||||||
run_applet_and_exit(applet_name, argv);
|
run_applet_and_exit(applet_name, argv);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
@ -910,7 +921,7 @@ void FAST_FUNC show_usage_if_dash_dash_help(int applet_no, char **argv)
|
|||||||
/* Special case. POSIX says "test --help"
|
/* Special case. POSIX says "test --help"
|
||||||
* should be no different from e.g. "test --foo".
|
* should be no different from e.g. "test --foo".
|
||||||
* Thus for "test", we skip --help check.
|
* Thus for "test", we skip --help check.
|
||||||
* "true" and "false" are also special.
|
* "true", "false", "echo" are also special.
|
||||||
*/
|
*/
|
||||||
if (1
|
if (1
|
||||||
# if defined APPLET_NO_test
|
# if defined APPLET_NO_test
|
||||||
@ -921,6 +932,9 @@ void FAST_FUNC show_usage_if_dash_dash_help(int applet_no, char **argv)
|
|||||||
# endif
|
# endif
|
||||||
# if defined APPLET_NO_false
|
# if defined APPLET_NO_false
|
||||||
&& applet_no != APPLET_NO_false
|
&& applet_no != APPLET_NO_false
|
||||||
|
# endif
|
||||||
|
# if defined APPLET_NO_echo
|
||||||
|
&& applet_no != APPLET_NO_echo
|
||||||
# endif
|
# endif
|
||||||
) {
|
) {
|
||||||
if (argv[1] && !argv[2] && strcmp(argv[1], "--help") == 0) {
|
if (argv[1] && !argv[2] && strcmp(argv[1], "--help") == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user