diff -rN -u old-ucspi-unix-1.0/unixclient.c new-ucspi-unix-1.0/unixclient.c --- old-ucspi-unix-1.0/unixclient.c 2020-10-10 20:09:42.852096610 +0200 +++ new-ucspi-unix-1.0/unixclient.c 2020-10-10 20:09:42.852096610 +0200 @@ -13,10 +13,14 @@ static const char* argv0; static const char* opt_socket; static char** command_argv; +static unsigned opt_quiet = 0; +static unsigned opt_verbose = 0; void die(const char* msg) { - perror(msg); + if(!opt_quiet) { + perror(msg); + } exit(1); } @@ -44,20 +48,27 @@ { if(message) fprintf(stderr, "%s: %s\n", argv0, message); - fprintf(stderr, "usage: %s [options] socket program\n" - " -q Quiet. Do not print any messages.\n" - " -Q (default) Print error messages.\n" - " -v Verbose. Print error and status messages.\n" - " -c N Do not handle more than N simultaneous connections.\n" - " (default 10)\n", argv0); + fprintf(stderr, + "usage: %s [options] socket program\n" + " -q Quiet. Do not print any messages.\n" + " -Q (default) Print error messages.\n" + " -v Verbose. Print error and status messages.\n", argv0); exit(1); } void parse_options(int argc, char* argv[]) { + int opt; argv0 = argv[0]; - ++argv; - --argc; + while((opt = getopt(argc, argv, "qQv")) != EOF) { + switch(opt) { + case 'q': opt_quiet = 1; opt_verbose = 0; break; + case 'Q': opt_quiet = 0; break; + case 'v': opt_quiet = 0; opt_verbose = 1; break; + } + } + argc -= optind; + argv += optind; if(argc < 2) usage(0); opt_socket = argv[0]; patch be48e9b5484a0ea65ec4fc2011a340e6f65cbb56 Author: Ben Franksen Date: Sat Oct 10 19:04:53 CEST 2020 * unixclient: actually handle the standard -q, -Q, and -v options