You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 1931 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Hi
I found that Arg module will always print more than what i want.
For example
some code:
let main () =
let speclist = [
("-t", Arg.String( print_endline) ,
"File types ");
("-v", Arg.String(print_endline) ,"show version information");
] in
let ano_fun s =
print_endline "Default"
in
Arg.parse speclist ano_fun "command [-t type] [-v string] "
let _ =
main();;
after complie as output ptk
when i type
./ptk -t
it will print the error message 3 time !
[climb@lcgfdr prj]$ ./ptk -t
./ptk: option -t' needs an argument. command [-t type] [-v string] -t File types -v show version information -help Display this list of options --help Display this list of options ./ptk: ./ptk: option -t' needs an argument.
command [-t type] [-v string]
-t File types
-v show version information
-help Display this list of options
--help Display this list of options
.
command [-t type] [-v string]
-t File types
-v show version information
-help Display this list of options
--help Display this list of options
and when i type
./ptk -t -v
it will print -v.
it will not print any error mesage.
however at this situation , it is a error input of args
Since i am new to Arg module , i am not quite sure is it a bug or not.
If not a bug, can you tell me how to avoid it ?
climb
The text was updated successfully, but these errors were encountered:
I found that Arg module will always print more than what i want.
./ptk -t
it will print the error message 3 time !
This is a bug. It is now fixed in the CVS version.
and when i type
./ptk -t -v
it will print -v.
it will not print any error mesage.
however at this situation , it is a error input of args
This is not a bug. The argument to "-t" is an arbitrary string, and it can
start with a "-". If we do otherwise, it becomes impossible to pass an
argument that starts with "-" to an option, and that would be too limiting.
Since i am new to Arg module , i am not quite sure is it a bug or not.
If not a bug, can you tell me how to avoid it ?
If you want to forbid a leading "-" in the "-t" argument, you need to
test it yourself as follows:
let check_t s =
if String.length s > 0 && s.[0] = '-'
then raise (Arg.Bad "bad argument to -t")
else print_endline s
;;
Original bug ID: 1931
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Hi
I found that Arg module will always print more than what i want.
For example
some code:
let main () =
let speclist = [
("-t", Arg.String( print_endline) ,
"File types ");
("-v", Arg.String(print_endline) ,"show version information");
] in
let ano_fun s =
print_endline "Default"
in
Arg.parse speclist ano_fun "command [-t type] [-v string] "
let _ =
main();;
after complie as output ptk
when i type
./ptk -t
it will print the error message 3 time !
[climb@lcgfdr prj]$ ./ptk -t
./ptk: option
-t' needs an argument. command [-t type] [-v string] -t File types -v show version information -help Display this list of options --help Display this list of options ./ptk: ./ptk: option
-t' needs an argument.command [-t type] [-v string]
-t File types
-v show version information
-help Display this list of options
--help Display this list of options
.
command [-t type] [-v string]
-t File types
-v show version information
-help Display this list of options
--help Display this list of options
and when i type
./ptk -t -v
it will print -v.
it will not print any error mesage.
however at this situation , it is a error input of args
Since i am new to Arg module , i am not quite sure is it a bug or not.
If not a bug, can you tell me how to avoid it ?
climb
The text was updated successfully, but these errors were encountered: