diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-06-03 23:36:56 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-06-03 23:36:56 -0700 |
commit | 5f47bf1a212b957009a85207338ee5b1d6ec6340 (patch) | |
tree | fba1cee39c4d5fa9401ab8fb5e2c13385c6edde0 /xvinfo.c | |
parent | 9798300fc71af02f8725bc7b4da47a4b8676f5ab (diff) |
Print which option was in error along with usage message
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'xvinfo.c')
-rw-r--r-- | xvinfo.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -12,10 +12,11 @@ static char *progname; -static void _X_NORETURN +static void _X_NORETURN _X_COLD PrintUsage(void) { - fprintf(stderr, "Usage: %s [-display host:dpy] [-short] [-version]\n", progname); + fprintf(stderr, "Usage: %s [-display host:dpy] [-short] [-version]\n", + progname); exit(0); } @@ -43,8 +44,12 @@ main(int argc, char *argv[]) if (argc != 1) { for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-display")) { - disname = argv[i + 1]; - i++; + if (++i >= argc) { + fprintf (stderr, "%s: missing argument to -display\n", + progname); + PrintUsage(); + } + disname = argv[i]; } else if (!strcmp(argv[i], "-short")) shortmode = 1; @@ -53,6 +58,8 @@ main(int argc, char *argv[]) exit(0); } else { + fprintf (stderr, "%s: unrecognized argument '%s'\n", + progname, argv[i]); PrintUsage(); } } |