Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007523OCamlstandard librarypublic2017-04-26 10:282017-04-26 10:42
ReporterSimon.cruanes 
Assigned Tooctachron 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformallOSallOS Version
Product Version4.03.0 
Target VersionFixed in Version4.05.0 +dev/beta1/beta2/beta3/rc1 
Summary0007523: bug in Arg when an option does not have its argument
DescriptionWhen a program written using Arg is not supplied well-formed options on the command line, an error message is displayed. However, in a particular case, the error message is output 3 times, not only one. This case seems to arise when the last parameter is an -option that has a mandatory argument.
The bug can be reproduced from 4.03 up to 4.04.1 and was initially reported by Florian Pichlmeier.
Steps To Reproduce# foo.ml
let () =
  Arg.parse [
    "--option", Arg.String (fun _ -> ()), " option <string>";
    ] (fun _ -> ()) "some help msg"


Then,

$ ocaml foo.ml --option
foo.ml: option '--option' needs an argument.
some help msg
  --option option <string>
  -help Display this list of options
  --help Display this list of options
foo.ml: foo.ml: option '--option' needs an argument.
some help msg
  --option option <string>
  -help Display this list of options
  --help Display this list of options
.
some help msg
  --option option <string>
  -help Display this list of options
  --help Display this list of options


whereas this works as expected:

$ ocaml foo.ml -bad-option
foo.ml: unknown option '-bad-option'.
some help msg
  --option option <string>
  -help Display this list of options
  --help Display this list of options
TagsNo tags attached.
Attached Files

- Relationships
has duplicate 0007578resolvedoctachron Arg.parse prints error message multiple times 

-  Notes
(0017755)
yallop (developer)
2017-04-26 10:30

Is this fixed by https://github.com/ocaml/ocaml/pull/999? [^]
(0017756)
octachron (developer)
2017-04-26 10:36

After verification, this was indeed fixed in 4.05 by https://github.com/ocaml/ocaml/pull/999 [^] but I unfortunately forgot to backport the fix to 4.04.1 .
(0017757)
Simon.cruanes (reporter)
2017-04-26 10:42

Ah, indeed. I could not find the report, even though it rang a bell. Sorry for the noise then.

- Issue History
Date Modified Username Field Change
2017-04-26 10:28 Simon.cruanes New Issue
2017-04-26 10:30 yallop Note Added: 0017755
2017-04-26 10:36 octachron Note Added: 0017756
2017-04-26 10:36 octachron Status new => resolved
2017-04-26 10:36 octachron Fixed in Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2017-04-26 10:36 octachron Resolution open => fixed
2017-04-26 10:36 octachron Assigned To => octachron
2017-04-26 10:42 Simon.cruanes Note Added: 0017757
2017-07-03 16:23 octachron Relationship added has duplicate 0007578


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker