diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-09-18 00:47:05 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-09-18 00:47:05 +0200 |
commit | cd7a38a87d54f5421b379870ff866676f31923b2 (patch) | |
tree | ddc2a3e74dcbf1cd0486e01c4f0e6c48bb445988 /libbb | |
parent | d0cdacafa98ec0e73e58c2e5a8ba9dded18006df (diff) | |
download | busybox-cd7a38a87d54f5421b379870ff866676f31923b2.tar.gz |
false: make "false --help" exit with 1
function old new delta
run_applet_no_and_exit 447 445 -2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/appletlib.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index a0150854a..cb16e310f 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -745,15 +745,25 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv) /* Reinit some shared global data */ xfunc_error_retval = EXIT_FAILURE; - applet_name = APPLET_NAME(applet_no); - if (argc == 2 && strcmp(argv[1], "--help") == 0) { - /* Special case. POSIX says "test --help" - * should be no different from e.g. "test --foo". */ -//TODO: just compare applet_no with APPLET_NO_test - if (!ENABLE_TEST || strcmp(applet_name, "test") != 0) { - /* If you want "foo --help" to return 0: */ - xfunc_error_retval = 0; + +#if defined APPLET_NO_test + /* Special case. POSIX says "test --help" + * should be no different from e.g. "test --foo". + * Thus for "test", we skip --help check. + */ + if (applet_no != APPLET_NO_test) +#endif + { + if (argc == 2 && strcmp(argv[1], "--help") == 0) { +#if defined APPLET_NO_false + /* Someone insisted that "false --help" must exit 1. Sigh */ + if (applet_no != APPLET_NO_false) +#endif + { + /* Make "foo --help" exit with 0: */ + xfunc_error_retval = 0; + } bb_show_usage(); } } |