summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2024-04-12 15:09:32 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-04-12 15:09:32 -0700
commitcf28e3bf739cda49e038cd53e8bb241fc1c2e81d (patch)
tree39c6771cddfcf06d158b96bbbc7ca635c0c8d052
parentea263607d3fbe4eca3319a3824c3f641dade4871 (diff)
Bypass Xrm for handling -help & -version argumentsHEADmaster
Closes: #1 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/app/xstdcmap/-/merge_requests/4>
-rw-r--r--xstdcmap.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/xstdcmap.c b/xstdcmap.c
index 03b6e67..c440a8b 100644
--- a/xstdcmap.c
+++ b/xstdcmap.c
@@ -341,6 +341,22 @@ main(int argc, char *argv[])
else
program_name = *argv;
+ /* Handle args that don't require opening a display or initializing Xrm */
+ for (int n = 1; n < argc; n++) {
+ const char *argn = argv[n];
+ /* accept single or double dash for -help & -version */
+ if (argn[0] == '-' && argn[1] == '-') {
+ argn++;
+ }
+ if (strcmp(argn, "-help") == 0) {
+ usage(0);
+ }
+ if (strcmp(argn, "-version") == 0) {
+ puts(PACKAGE_STRING);
+ exit(0);
+ }
+ }
+
parse(argc, argv);
if (help) {