1
0
Fork 0
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:
Steffen Vogel 2016-10-30 22:05:29 -04:00
parent 3e93dfe17c
commit 800e71bb96
4 changed files with 6 additions and 11 deletions

View file

@ -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);
}
}

View file

@ -203,6 +203,7 @@ int main(int argc, char *argv[])
case 'h':
case '?':
usage();
exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS);
}
}

View file

@ -102,6 +102,7 @@ int main(int argc, char *argv[])
case 'h':
case '?':
usage();
exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS);
}
continue;

View file

@ -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;