From cf28e3bf739cda49e038cd53e8bb241fc1c2e81d Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 12 Apr 2024 15:09:32 -0700 Subject: Bypass Xrm for handling -help & -version arguments Closes: #1 Signed-off-by: Alan Coopersmith Part-of: --- xstdcmap.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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) { -- cgit v1.2.3