mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
proper return codes for incorrect CLI arguments
This commit is contained in:
parent
3e93dfe17c
commit
800e71bb96
4 changed files with 6 additions and 11 deletions
|
@ -53,8 +53,8 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage(argv[0]);
|
||||
exit(EXIT_SUCCESS);
|
||||
usage();
|
||||
exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -203,6 +203,7 @@ int main(int argc, char *argv[])
|
|||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ int main(int argc, char *argv[])
|
|||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
|
11
src/test.c
11
src/test.c
|
@ -114,15 +114,8 @@ int main(int argc, char *argv[])
|
|||
res = strtod(optarg, &endptr);
|
||||
goto check;
|
||||
case '?':
|
||||
if (optopt == 'c')
|
||||
error("Option -%c requires an argument.", optopt);
|
||||
else if (isprint(optopt))
|
||||
error("Unknown option '-%c'.", optopt);
|
||||
else
|
||||
error("Unknown option character '\\x%x'.", optopt);
|
||||
exit(EXIT_FAILURE);
|
||||
default:
|
||||
abort();
|
||||
usage();
|
||||
exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
|
Loading…
Add table
Reference in a new issue