1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 11:02:48 -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

@ -186,6 +186,7 @@ int main(int argc, char **argv)
int i, skcount, sksize, socketstate;
int connopen;
int exitcode;
int errors;
void *ldisc;
ssh_get_line = console_get_line;
@ -206,6 +207,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.
@ -230,6 +232,7 @@ 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) {
@ -237,11 +240,17 @@ int main(int argc, char **argv)
} else if (!strcmp(p, "-batch")) {
console_batch_mode = 1;
} else if (!strcmp(p, "-o")) {
if (argc <= 1)
if (argc <= 1) {
fprintf(stderr,
"plink: option \"-o\" requires an argument\n");
else
--argc, provide_xrm_string(*++argv);
errors = 1;
} else {
--argc;
provide_xrm_string(*++argv);
}
} else {
fprintf(stderr, "plink: unknown option \"%s\"\n", p);
errors = 1;
}
} else if (*p) {
if (!*cfg.host) {
@ -366,6 +375,9 @@ int main(int argc, char **argv)
}
}
if (errors)
return 1;
if (!*cfg.host) {
usage();
}