diff options
author | Jason Nader <jason.nader@protonmail.com> | 2020-04-11 22:29:47 +0900 |
---|---|---|
committer | Jason Nader <jason.nader@protonmail.com> | 2020-04-11 22:41:24 +0900 |
commit | 632461227686bb31004fd9cf823bcf1645e7a563 (patch) | |
tree | 8c8c3f165ac95438a2924a5eda06b9c88961e710 /xprop.c | |
parent | e81642bacc58388c223bc157f37c2311a7dbe070 (diff) |
Add missing `-help` function
`-help` is mentioned in the manpages, but actually running `xprop -help`
results in xprop exiting with status 1 as it doesn't recognise the option.
This has been the source of major confusion here:
https://github.com/franciscolourenco/done/issues/77#issuecomment-612404448
Signed-off-by: Jason Nader <jason.nader@protonmail.com>
Diffstat (limited to 'xprop.c')
-rw-r--r-- | xprop.c | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -1772,10 +1772,11 @@ Set_Property (Display *dpy, Window w, const char *propname, const char *value) */ void -usage (const char *errmsg) +print_help (void) { static const char *help_message = "where options include:\n" +" -help print out a summary of command line options\n" " -grammar print out full grammar for command line\n" " -display host:dpy the X server to contact\n" " -id id resource id of window to examine\n" @@ -1795,13 +1796,24 @@ usage (const char *errmsg) fflush (stdout); - if (errmsg != NULL) - fprintf (stderr, "%s: %s\n\n", program_name, errmsg); - fprintf (stderr, "usage: %s [-options ...] [[format [dformat]] atom] ...\n\n", program_name); fprintf (stderr, "%s\n", help_message); +} + +void help (void) { + print_help(); + exit(0); +} + +void +usage (const char *errmsg) +{ + if (errmsg != NULL) + fprintf (stderr, "%s: %s\n\n", program_name, errmsg); + + print_help(); exit (1); } @@ -1918,6 +1930,10 @@ main (int argc, char **argv) while (argv++, --argc>0 && **argv == '-') { if (!strcmp(argv[0], "-")) continue; + if (!strcmp(argv[0], "-help")) { + help (); + /* NOTREACHED */ + } if (!strcmp(argv[0], "-grammar")) { grammar (); /* NOTREACHED */ |