On Fri, 19 Sep 2025 12:30:07 -0400 Chet Ramey wrote:
> > > It would not, but you're in the right neighborhood.
> > > I'll take care of it.
> > 
> > Are you sure that it's not enough? I just built a fresh new bash with the
> > following patch, and it seems to have solved everything for me:
> 
> Yes. Try builtins such as break, continue, caller, fg, bg, getopts,
> times, etc. that don't accept options but accept --help.

You're right. Patch corrected.

Bash rebuilt. Tested. It took care of: break, continue, caller,
fg, bg.  I tested each one of these.

You mentioned times, but times does not accept --help.

getopts is the odd one out. A "--help" vs. "--yelp" test confirms
that it does recognize the option as valid. Only, I don't completely 
understand its source code.

At this point I wouldn't mind if getopts remains the only exception
to the rule. If it's not an easy fix, you may as well skip this one.
There are some examples of external commands that don't abide to the
"return 0 on --help" rule anyway.

---------------------------------------------------------------
--- builtins/common.h  Wed Oct 23 14:40:02 2024
+++ -  Fri Sep 19 10:55:43 2025
@@ -31,14 +31,14 @@
   if ((l) && (l)->word && ISHELP((l)->word->word)) \
     { \
       builtin_help (); \
-      return (EX_USAGE); \
+      return (EXECUTION_SUCCESS); \
     } \
 } while (0)
 
 #define CASE_HELPOPT \
   case GETOPT_HELP: \
     builtin_help (); \
-    return (EX_USAGE)
+    return (EXECUTION_SUCCESS)
 
 /* Flag values for parse_and_execute () and parse_string () */
 #define SEVAL_NONINT  0x001
---------------------------------------------------------------

Pourko.


Reply via email to