mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-22 14:46:57 -04:00
check_icmp: fix parsing help/version long options
Fix parsing of the long options --help and --version. The special
handling must be done before calling getopt().
This fixes erroneous output like:
./check_icmp --version
./check_icmp: invalid option -- '-'
./check_icmp: invalid option -- 'e'
./check_icmp: invalid option -- 'r'
./check_icmp: invalid option -- '-'
./check_icmp: invalid option -- 'e'
./check_icmp: invalid option -- 'r'
Signed-off-by: Aksel Sjögren <asjogren@itrsgroup.com>
This commit is contained in:
parent
1bc6d81651
commit
e5db81bb29
1 changed files with 8 additions and 8 deletions
|
|
@ -451,6 +451,14 @@ main(int argc, char **argv)
|
|||
packets = 5;
|
||||
}
|
||||
|
||||
/* support "--help" and "--version" */
|
||||
if(argc == 2) {
|
||||
if(!strcmp(argv[1], "--help"))
|
||||
strcpy(argv[1], "-h");
|
||||
if(!strcmp(argv[1], "--version"))
|
||||
strcpy(argv[1], "-V");
|
||||
}
|
||||
|
||||
/* Parse protocol arguments first */
|
||||
for(i = 1; i < argc; i++) {
|
||||
while((arg = getopt(argc, argv, opts_str)) != EOF) {
|
||||
|
|
@ -555,14 +563,6 @@ main(int argc, char **argv)
|
|||
/* Parse extra opts if any */
|
||||
argv=np_extra_opts(&argc, argv, progname);
|
||||
|
||||
/* support "--help" and "--version" */
|
||||
if(argc == 2) {
|
||||
if(!strcmp(argv[1], "--help"))
|
||||
strcpy(argv[1], "-h");
|
||||
if(!strcmp(argv[1], "--version"))
|
||||
strcpy(argv[1], "-V");
|
||||
}
|
||||
|
||||
argv = &argv[optind];
|
||||
while(*argv) {
|
||||
add_target(*argv);
|
||||
|
|
|
|||
Loading…
Reference in a new issue