diff --git a/unix/vncconfig/vncconfig.cxx b/unix/vncconfig/vncconfig.cxx index 75bf840de..94ece6da7 100644 --- a/unix/vncconfig/vncconfig.cxx +++ b/unix/vncconfig/vncconfig.cxx @@ -296,18 +296,34 @@ int main(int argc, char** argv) if (i >= argc) usage(); char* equal = strchr(argv[i], '='); - if (!equal) - usage(); + if (!equal) { + fprintf(stderr, "%s: Invalid parameter syntax '%s'\n", + programName, argv[i]); + fprintf(stderr, "See '%s -help' for more information.\n", + programName); + exit(1); + } std::string name(argv[i], equal-argv[i]); std::string value(equal+1); if (!XVncExtSetParam(dpy, name.c_str(), value.c_str())) fprintf(stderr, "Setting param %s failed\n",argv[i]); + } else if (argv[i][0] == '-') { + fprintf(stderr, "%s: Unrecognized option '%s'\n", + programName, argv[i]); + fprintf(stderr, "See '%s -help' for more information.\n", + programName); + exit(1); } else { char* equal = strchr(argv[i], '='); - if (!equal) - usage(); + if (!equal) { + fprintf(stderr, "%s: Invalid parameter syntax '%s'\n", + programName, argv[i]); + fprintf(stderr, "See '%s -help' for more information.\n", + programName); + exit(1); + } std::string name(argv[i], equal-argv[i]); std::string value(equal+1); diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx index c49af11fb..84d3d0df1 100644 --- a/unix/vncpasswd/vncpasswd.cxx +++ b/unix/vncpasswd/vncpasswd.cxx @@ -202,7 +202,9 @@ int main(int argc, char** argv) } else if (strncmp(argv[i], "-f", 2) == 0) { return encrypt_pipe(); } else if (argv[i][0] == '-') { - usage(); + fprintf(stderr, "%s: Unrecognized option '%s'\n", prog, argv[i]); + fprintf(stderr, "See '%s --help' for more information.\n", prog); + exit(1); } else if (fname[0] == '\0') { if (strlen(argv[i]) >= sizeof(fname)) { fprintf(stderr, "Too long filename specified\n"); @@ -210,7 +212,9 @@ int main(int argc, char** argv) } strcpy(fname, argv[i]); } else { - usage(); + fprintf(stderr, "%s: Extra argument '%s'\n", prog, argv[i]); + fprintf(stderr, "See '%s --help' for more information.\n", prog); + exit(1); } } diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx index 6c46220a6..bc0efdddc 100644 --- a/unix/x0vncserver/x0vncserver.cxx +++ b/unix/x0vncserver/x0vncserver.cxx @@ -307,7 +307,18 @@ int main(int argc, char** argv) return 0; } - usage(); + if (argv[i][0] == '-') { + fprintf(stderr, "%s: Unrecognized option '%s'\n", + programName, argv[i]); + fprintf(stderr, "See '%s --help' for more information.\n", + programName); + exit(1); + } + + fprintf(stderr, "%s: Extra argument '%s'\n", programName, argv[i]); + fprintf(stderr, "See '%s --help' for more information.\n", + programName); + exit(1); } if (!(dpy = XOpenDisplay(displayname))) { diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index 3beaab148..c5cb03317 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -694,11 +694,22 @@ int main(int argc, char** argv) return 0; } - if (argv[i][0] == '-') - usage(argv[0]); + if (argv[i][0] == '-') { + fprintf(stderr, "\n"); + fprintf(stderr, "%s: Unrecognized option '%s'\n", + argv[0], argv[i]); + fprintf(stderr, "See '%s --help' for more information.\n", + argv[0]); + exit(1); + } - if (vncServerName[0] != '\0') - usage(argv[0]); + if (vncServerName[0] != '\0') { + fprintf(stderr, "\n"); + fprintf(stderr, "%s: Extra argument '%s'\n", argv[0], argv[i]); + fprintf(stderr, "See '%s --help' for more information.\n", + argv[0]); + exit(0); + } strncpy(vncServerName, argv[i], VNCSERVERNAMELEN); vncServerName[VNCSERVERNAMELEN - 1] = '\0';