Add condition to prevent options -o and -e being used together

This commit is contained in:
Shan-Chun Kuo 2017-04-07 16:24:29 +01:00
parent a320248857
commit 682a272f91

View File

@ -1863,6 +1863,15 @@ static bool has_name(struct option *long_options, int *pl) {
return false;
}
static bool findFlag(int argc, char **argv, std::string str) {
char **ptr = std::find(argv, argv + argc, str);
if (ptr != argv + argc)
return true;
else
return false;
}
int main(int argc, char **argv) {
#ifdef MTRACE
mtrace();
@ -2256,6 +2265,11 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
if ((findFlag(argc, argv, "-o") && findFlag(argc, argv, "-e")) || (findFlag(argc, argv, "--output") && findFlag(argc, argv, "--output-to-directory"))) {
fprintf(stderr, "%s: Options -o and -e cannot be used together\n", argv[0]);
exit(EXIT_FAILURE);
}
if (force) {
unlink(outdir);
}