mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-12 18:13:50 -05:00
Unix Pageant: move handling of --exec arguments.
Now --exec instantly terminates option processing, by treating everything after it as the command. This means it doesn't matter if the --exec command word looks like another option, and it also means we can simplify the handling of real non-option argument words, when I get round to adding some for loading keys.
This commit is contained in:
parent
2069de8c8f
commit
8228085c54
@ -266,7 +266,7 @@ int main(int argc, char **argv)
|
||||
/*
|
||||
* Process the command line.
|
||||
*/
|
||||
while (--argc) {
|
||||
while (--argc > 0) {
|
||||
char *p = *++argv;
|
||||
if (*p == '-' && doing_opts) {
|
||||
if (!strcmp(p, "-V") || !strcmp(p, "--version")) {
|
||||
@ -286,17 +286,21 @@ int main(int argc, char **argv)
|
||||
life = LIFE_PERM;
|
||||
} else if (!strcmp(p, "--exec")) {
|
||||
life = LIFE_EXEC;
|
||||
/* Now all subsequent arguments go to the exec command. */
|
||||
if (--argc > 0) {
|
||||
exec_args = ++argv;
|
||||
argc = 0; /* force end of option processing */
|
||||
} else {
|
||||
fprintf(stderr, "pageant: expected a command "
|
||||
"after --exec\n");
|
||||
exit(1);
|
||||
}
|
||||
} else if (!strcmp(p, "--")) {
|
||||
doing_opts = FALSE;
|
||||
}
|
||||
} else {
|
||||
if (life == LIFE_EXEC) {
|
||||
exec_args = argv;
|
||||
break; /* everything else is now args to the exec command */
|
||||
} else {
|
||||
fprintf(stderr, "pageant: unexpected argument '%s'\n", p);
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "pageant: unexpected argument '%s'\n", p);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user