diff --git a/Changes b/Changes index f1f2ec9b1..174d9104b 100644 --- a/Changes +++ b/Changes @@ -35,6 +35,8 @@ Standard library: . Added optional "seed" parameter to Hashtbl.create for diversification . Added new functorial interface "MakeSeeded" to support diversification with user-provided hash functions. +- Arg: options with empty doc strings are no longer included in the usage string + (PR#5437) Bug Fixes: - PR#4869: rare collisions between assembly labels for code and data diff --git a/stdlib/arg.ml b/stdlib/arg.ml index d5d1bdf74..d19f89056 100644 --- a/stdlib/arg.ml +++ b/stdlib/arg.ml @@ -64,10 +64,11 @@ let make_symlist prefix sep suffix l = ;; let print_spec buf (key, spec, doc) = - match spec with - | Symbol (l, _) -> bprintf buf " %s %s%s\n" key (make_symlist "{" "|" "}" l) - doc - | _ -> bprintf buf " %s %s\n" key doc + if String.length doc > 0 then + match spec with + | Symbol (l, _) -> bprintf buf " %s %s%s\n" key (make_symlist "{" "|" "}" l) + doc + | _ -> bprintf buf " %s %s\n" key doc ;; let help_action () = raise (Stop (Unknown "-help"));; diff --git a/stdlib/arg.mli b/stdlib/arg.mli index 1fff78f19..d6e0210aa 100644 --- a/stdlib/arg.mli +++ b/stdlib/arg.mli @@ -83,6 +83,8 @@ val parse : - The reason for the error: unknown option, invalid or missing argument, etc. - [usage_msg] - The list of options, each followed by the corresponding [doc] string. + Beware: options that have an empty [doc] string will not be included in the + list. For the user to be able to specify anonymous arguments starting with a [-], include for example [("-", String anon_fun, doc)] in [speclist].