Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007578OCamlstandard librarypublic2017-07-03 16:182017-07-03 16:23
ReporterRichard-Degenne 
Assigned Tooctachron 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionduplicate 
PlatformOSOS Version
Product Version4.04.2 
Target VersionFixed in Version4.05.0 +dev/beta1/beta2/beta3/rc1 
Summary0007578: Arg.parse prints error message multiple times
DescriptionWhen using the `Arg` module, a missing argument will trigger an error.

However, the error message is printed 3 times in a row instead of only once.

*Note* : I tried the same piece of code with 4.03.0 and 4.02.3, and was unable to reproduce.
Steps To ReproduceWith OCaml 4.04.2,

- Create a file `cli.ml` containing the following:


```
(* cli.ml *)

let usage = "usage: " ^ Sys.argv.(0) ^ " [-d int]"

let speclist = [
  ("-d", Arg.Set_int someint, ": some int parameter");
]

let () =
  Arg.parse
    speclist
    (fun x -> raise (Arg.Bad ("Bad argument : " ^ x)))
    usage;
  Printf.printf "%d\n" !someint
```

- Run with `$ ocaml cli.ml -d` (note the missing argument after -d)

- Look at the error message:

```
cli.ml: option '-d' needs an argument.
usage: cli.ml [-d int]
  -d : some int parameter
  -help Display this list of options
  --help Display this list of options
cli.ml: cli.ml: option '-d' needs an argument.
usage: cli.ml [-d int]
  -d : some int parameter
  -help Display this list of options
  --help Display this list of options
.
usage: cli.ml [-d int]
  -d : some int parameter
  -help Display this list of options
  --help Display this list of options
```g
TagsNo tags attached.
Attached Files

- Relationships
duplicate of 0007523resolvedoctachron bug in Arg when an option does not have its argument 

-  Notes
(0018040)
Richard-Degenne (reporter)
2017-07-03 16:20

Crap, as soon as I file this, I find it's a duplicate of 0007523.

Sorry. :(
(0018041)
octachron (developer)
2017-07-03 16:21

This is fixed in 4.05, see https://github.com/ocaml/ocaml/blob/trunk/Changes#L455 [^] and https://github.com/ocaml/ocaml/pull/999 [^] for more information.
(0018042)
octachron (developer)
2017-07-03 16:23

Thanks for reporting and finding the right duplicate id.

- Issue History
Date Modified Username Field Change
2017-07-03 16:18 Richard-Degenne New Issue
2017-07-03 16:20 Richard-Degenne Note Added: 0018040
2017-07-03 16:21 octachron Note Added: 0018041
2017-07-03 16:23 octachron Note Added: 0018042
2017-07-03 16:23 octachron Relationship added duplicate of 0007523
2017-07-03 16:23 octachron Status new => resolved
2017-07-03 16:23 octachron Fixed in Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2017-07-03 16:23 octachron Resolution open => duplicate
2017-07-03 16:23 octachron Assigned To => octachron


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker