diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-05 09:36:55 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-05 10:07:49 -0800 |
commit | 851c85cba5ec8c0e59fba3aebed7c91e5711431b (patch) | |
tree | 0471133297b82a7622d42008ec7a9f46dcb12851 | |
parent | c19461e94f457173b06efa634d9eb540271ea6ae (diff) |
Fix -version handling to not require opening a display first
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | xconsole.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -615,14 +615,22 @@ main(int argc, char *argv[]) Cardinal num_args; XtSetLanguageProc(NULL,NULL,NULL); + + /* Handle args that don't require opening a display */ + for (int n = 1; n < argc; n++) { + const char *argn = argv[n]; + /* accept single or double dash for -version */ + if (argn[0] == '-' && argn[1] == '-') { + argn++; + } + if (strcmp(argn, "-version") == 0) { + puts(PACKAGE_STRING); + exit(0); + } + } + top = XtInitialize ("xconsole", "XConsole", options, XtNumber (options), &argc, argv); - if ((argc == 2) && - ((strcmp(argv[1], "-version") == 0) || - (strcmp(argv[1], "--version") == 0))) { - puts(PACKAGE_STRING); - exit(0); - } XtGetApplicationResources (top, (XtPointer)&app_resources, resources, XtNumber (resources), NULL, 0); |