1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-13 00:57:33 -05:00

Fixes for more robust handling of command-line parse errors.

[originally from svn r2236]
This commit is contained in:
Simon Tatham
2002-11-20 20:09:02 +00:00
parent 75ebfa28f0
commit 0c110dcd10
5 changed files with 35 additions and 9 deletions

View File

@ -256,6 +256,7 @@ int main(int argc, char **argv)
int skcount, sksize;
int connopen;
int exitcode;
int errors;
ssh_get_line = console_get_line;
@ -275,6 +276,7 @@ int main(int argc, char **argv)
do_defaults(NULL, &cfg);
default_protocol = cfg.protocol;
default_port = cfg.port;
errors = 0;
{
/*
* Override the default protocol if PLINK_PROTOCOL is set.
@ -299,12 +301,16 @@ int main(int argc, char **argv)
if (ret == -2) {
fprintf(stderr,
"plink: option \"%s\" requires an argument\n", p);
errors = 1;
} else if (ret == 2) {
--argc, ++argv;
} else if (ret == 1) {
continue;
} else if (!strcmp(p, "-batch")) {
console_batch_mode = 1;
} else {
fprintf(stderr, "plink: unknown option \"%s\"\n", p);
errors = 1;
}
} else if (*p) {
if (!*cfg.host) {
@ -426,6 +432,9 @@ int main(int argc, char **argv)
}
}
if (errors)
return 1;
if (!*cfg.host) {
usage();
}