diff options
author | Ron Yorston <rmy@pobox.com> | 2021-05-14 08:17:12 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-05-14 08:17:12 +0100 |
commit | a3f5a1b7f4275f713acf22f534f95c0da8392e53 (patch) | |
tree | 49b65422a3e9c33f508da9ccf3ae79d324bd9e96 /libbb/appletlib.c | |
parent | 375cda9a88024135d630ca8990d9aff4ea414e89 (diff) | |
parent | 7de0ab21d939a5a304157f75918d0318a95261a3 (diff) | |
download | busybox-w32-a3f5a1b7f4275f713acf22f534f95c0da8392e53.tar.gz busybox-w32-a3f5a1b7f4275f713acf22f534f95c0da8392e53.tar.bz2 busybox-w32-a3f5a1b7f4275f713acf22f534f95c0da8392e53.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb/appletlib.c')
-rw-r--r-- | libbb/appletlib.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 193a78e31..f53d74834 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -278,9 +278,14 @@ void lbb_prepare(const char *applet | |||
278 | && strcmp(argv[1], "--help") == 0 | 278 | && strcmp(argv[1], "--help") == 0 |
279 | && !is_prefixed_with(applet, "busybox") | 279 | && !is_prefixed_with(applet, "busybox") |
280 | ) { | 280 | ) { |
281 | /* Special case. POSIX says "test --help" | 281 | /* Special cases. POSIX says "test --help" |
282 | * should be no different from e.g. "test --foo". */ | 282 | * should be no different from e.g. "test --foo". |
283 | if (!ENABLE_TEST || strcmp(applet_name, "test") != 0) | 283 | */ |
284 | if (!(ENABLE_TEST && strcmp(applet_name, "test") == 0) | ||
285 | && !(ENABLE_TRUE && strcmp(applet_name, "true") == 0) | ||
286 | && !(ENABLE_FALSE && strcmp(applet_name, "false") == 0) | ||
287 | && !(ENABLE_ECHO && strcmp(applet_name, "echo") == 0) | ||
288 | ) | ||
284 | bb_show_usage(); | 289 | bb_show_usage(); |
285 | } | 290 | } |
286 | #endif | 291 | #endif |
@@ -1021,15 +1026,21 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) | |||
1021 | if (!argv[2]) | 1026 | if (!argv[2]) |
1022 | goto help; | 1027 | goto help; |
1023 | /* convert to "<applet> --help" */ | 1028 | /* convert to "<applet> --help" */ |
1024 | argv[0] = argv[2]; | 1029 | applet_name = argv[0] = argv[2]; |
1025 | argv[2] = NULL; | 1030 | argv[2] = NULL; |
1031 | if (find_applet_by_name(applet_name) >= 0) { | ||
1032 | /* Make "--help foo" exit with 0: */ | ||
1033 | xfunc_error_retval = 0; | ||
1034 | bb_show_usage(); | ||
1035 | } /* else: unknown applet, fall through (causes "applet not found" later) */ | ||
1026 | } else { | 1036 | } else { |
1027 | /* "busybox <applet> arg1 arg2 ..." */ | 1037 | /* "busybox <applet> arg1 arg2 ..." */ |
1028 | argv++; | 1038 | argv++; |
1039 | /* We support "busybox /a/path/to/applet args..." too. Allows for | ||
1040 | * "#!/bin/busybox"-style wrappers | ||
1041 | */ | ||
1042 | applet_name = bb_get_last_path_component_nostrip(argv[0]); | ||
1029 | } | 1043 | } |
1030 | /* We support "busybox /a/path/to/applet args..." too. Allows for | ||
1031 | * "#!/bin/busybox"-style wrappers */ | ||
1032 | applet_name = bb_get_last_path_component_nostrip(argv[0]); | ||
1033 | run_applet_and_exit(applet_name, argv); | 1044 | run_applet_and_exit(applet_name, argv); |
1034 | } | 1045 | } |
1035 | # endif | 1046 | # endif |
@@ -1040,7 +1051,7 @@ void FAST_FUNC show_usage_if_dash_dash_help(int applet_no, char **argv) | |||
1040 | /* Special case. POSIX says "test --help" | 1051 | /* Special case. POSIX says "test --help" |
1041 | * should be no different from e.g. "test --foo". | 1052 | * should be no different from e.g. "test --foo". |
1042 | * Thus for "test", we skip --help check. | 1053 | * Thus for "test", we skip --help check. |
1043 | * "true" and "false" are also special. | 1054 | * "true", "false", "echo" are also special. |
1044 | */ | 1055 | */ |
1045 | if (1 | 1056 | if (1 |
1046 | # if defined APPLET_NO_test | 1057 | # if defined APPLET_NO_test |
@@ -1052,6 +1063,9 @@ void FAST_FUNC show_usage_if_dash_dash_help(int applet_no, char **argv) | |||
1052 | # if defined APPLET_NO_false | 1063 | # if defined APPLET_NO_false |
1053 | && applet_no != APPLET_NO_false | 1064 | && applet_no != APPLET_NO_false |
1054 | # endif | 1065 | # endif |
1066 | # if defined APPLET_NO_echo | ||
1067 | && applet_no != APPLET_NO_echo | ||
1068 | # endif | ||
1055 | # if ENABLE_PLATFORM_MINGW32 && defined APPLET_NO_busybox | 1069 | # if ENABLE_PLATFORM_MINGW32 && defined APPLET_NO_busybox |
1056 | && applet_no != APPLET_NO_busybox | 1070 | && applet_no != APPLET_NO_busybox |
1057 | # endif | 1071 | # endif |