summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xkill.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/xkill.c b/xkill.c
index 2270dcd..32cb0cc 100644
--- a/xkill.c
+++ b/xkill.c
@@ -73,7 +73,7 @@ Exit(int code, Display *dpy)
}
static void _X_NORETURN
-usage(void)
+usage(const char *errmsg)
{
const char *options =
"where options include:\n"
@@ -85,6 +85,9 @@ usage(void)
" -version print version and exit\n"
"\n";
+ if (errmsg != NULL)
+ fprintf (stderr, "%s: %s\n\n", ProgramName, errmsg);
+
fprintf (stderr, "usage: %s [-option ...]\n%s",
ProgramName, options);
Exit (1, NULL);
@@ -112,11 +115,11 @@ main(int argc, char *argv[])
if (arg[0] == '-') {
switch (arg[1]) {
case 'd': /* -display displayname */
- if (++i >= argc) usage ();
+ if (++i >= argc) usage ("-display requires an argument");
displayname = argv[i];
continue;
case 'i': /* -id resourceid */
- if (++i >= argc) usage ();
+ if (++i >= argc) usage ("-id requires an argument");
id = strtoul (argv[i], NULL, 0);
if (id == 0 || id >= 0xFFFFFFFFU) {
fprintf (stderr, "%s: invalid id \"%s\"\n",
@@ -125,7 +128,7 @@ main(int argc, char *argv[])
}
continue;
case 'b': /* -button number */
- if (++i >= argc) usage ();
+ if (++i >= argc) usage ("-button requires an argument");
button_name = argv[i];
continue;
case 'f': /* -frame */
@@ -138,10 +141,14 @@ main(int argc, char *argv[])
puts(PACKAGE_STRING);
exit(0);
default:
- usage ();
+ fprintf(stderr, "%s: unrecognized argument %s\n\n",
+ ProgramName, arg);
+ usage (NULL);
}
} else {
- usage ();
+ fprintf(stderr, "%s: unrecognized argument %s\n\n",
+ ProgramName, arg);
+ usage (NULL);
}
} /* end for */