Thank you for finding this bug. I committed a somewhat different fix, one which factors out the code to detect --help (some applets opt out of handling it specially).
On Thu, Feb 18, 2021 at 8:44 AM Ron Yorston <[email protected]> wrote: > > Most BusyBox applets respond to the '--help' option by printing > a usage message. This is normally handled by busybox_main() so > applet main routines don't have support for '--help'. > > In standalone shell mode with FEATURE_SH_NOFORK enabled nofork > applets are invoked directly, bypassing busybox_main(). This > results in inconsistent handling of '--help': > > - applets which call getopt() report "unrecognized option '--help'" > and print help anyway; > > - realpath says "--help: No such file or directory" and doesn't > print help; > > - usleep says "invalid number '--help'" and doesn't print help. > > Avoid inconsistency by checking for '--help' in run_nofork_applet(). > > Signed-off-by: Ron Yorston <[email protected]> > --- > libbb/vfork_daemon_rexec.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c > index 65271e84f..a9ce280dd 100644 > --- a/libbb/vfork_daemon_rexec.c > +++ b/libbb/vfork_daemon_rexec.c > @@ -109,6 +109,8 @@ int FAST_FUNC run_nofork_applet(int applet_no, char > **argv) > char *tmp_argv[argc+1]; > memcpy(tmp_argv, argv, (argc+1) * sizeof(tmp_argv[0])); > applet_name = tmp_argv[0]; > + if (argc == 2 && strcmp(argv[1], "--help") == 0) > + bb_show_usage(); > /* Finally we can call NOFORK applet's main() */ > rc = applet_main[applet_no](argc, tmp_argv); > /* Important for shells: `which CMD` was failing */ > -- > 2.29.2 > > _______________________________________________ > busybox mailing list > [email protected] > http://lists.busybox.net/mailman/listinfo/busybox _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
