Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2022-05-01 11:45:37 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2022-08-22 15:05:01 +0300
commit5a9d2b6e024e6c20d4d7b8c170985554c0df043d (patch)
tree5edc52e4c2e89e536750155c49fe6c9d6ca56f2b /libbb
parent41d5f800a14769704082f7faeabb8435285499be (diff)
libbb: make '--help' handling more consistent
Running an applet with '--help' as its only argument is treated as a special case. If additional arguments follow '--help' the behaviour is inconsistent: - applets which call single_argv() print help and do nothing else; - applets which call getopt() report "unrecognized option '--help'" and print help anyway; - expr says "expr: syntax error" and doesn't print help; - printenv silently ignores '--help', prints any other variables and doesn't print help; - realpath says "--help: No such file or directory", prints the path of any other files and doesn't print help. If the first argument is '--help' ignore any other arguments and print help. This is more consistent and most likely what the user wanted. See also commit 6bdfbc4cb (libbb: fix '--help' handling in FEATURE_SH_NOFORK=y). function old new delta show_usage_if_dash_dash_help 75 69 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-6) Total: -6 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/appletlib.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index d8ab2a450..9b9d7dbd6 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -258,7 +258,6 @@ void lbb_prepare(const char *applet
/* Redundant for busybox (run_applet_and_exit covers that case)
* but needed for "individual applet" mode */
if (argv[1]
- && !argv[2]
&& strcmp(argv[1], "--help") == 0
&& !is_prefixed_with(applet, "busybox")
) {
@@ -940,8 +939,8 @@ void FAST_FUNC show_usage_if_dash_dash_help(int applet_no, char **argv)
&& applet_no != APPLET_NO_echo
# endif
) {
- if (argv[1] && !argv[2] && strcmp(argv[1], "--help") == 0) {
- /* Make "foo --help" exit with 0: */
+ if (argv[1] && strcmp(argv[1], "--help") == 0) {
+ /* Make "foo --help [...]" exit with 0: */
xfunc_error_retval = 0;
bb_show_usage();
}