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

bug in Arg when an option does not have its argument #7523

Closed
vicuna opened this Issue Apr 26, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Apr 26, 2017

Original bug ID: 7523
Reporter: @c-cube
Assigned to: @Octachron
Status: resolved (set by @Octachron on 2017-04-26T08:36:08Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: all
OS: all
Version: 4.03.0
Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: standard library
Has duplicate: #7578

Bug description

When 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 ";
] (fun _ -> ()) "some help msg"

Then,

$ ocaml foo.ml --option
foo.ml: option '--option' needs an argument.
some help msg
--option option
-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
-help Display this list of options
--help Display this list of options
.
some help msg
--option option
-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
-help Display this list of options
--help Display this list of options

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Apr 26, 2017

Comment author: @yallop

Is this fixed by #999?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Apr 26, 2017

Comment author: @Octachron

After verification, this was indeed fixed in 4.05 by #999 but I unfortunately forgot to backport the fix to 4.04.1 .

@vicuna vicuna closed this Apr 26, 2017

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Apr 26, 2017

Comment author: @c-cube

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.