Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arg.parse prints error message multiple times #7578

Closed
vicuna opened this issue Jul 3, 2017 · 3 comments
Closed

Arg.parse prints error message multiple times #7578

vicuna opened this issue Jul 3, 2017 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Jul 3, 2017

Original bug ID: 7578
Reporter: Richard-Degenne
Assigned to: @Octachron
Status: resolved (set by @Octachron on 2017-07-03T14:23:48Z)
Resolution: duplicate
Priority: normal
Severity: minor
Version: 4.04.2
Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: standard library
Duplicate of: #7523

Bug description

When 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 reproduce

With 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
@vicuna
Copy link
Author

vicuna commented Jul 3, 2017

Comment author: Richard-Degenne

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

Sorry. :(

@vicuna
Copy link
Author

vicuna commented Jul 3, 2017

Comment author: @Octachron

This is fixed in 4.05, see https://github.com/ocaml/ocaml/blob/trunk/Changes#L455 and #999 for more information.

@vicuna
Copy link
Author

vicuna commented Jul 3, 2017

Comment author: @Octachron

Thanks for reporting and finding the right duplicate id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants