summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2020-06-17 15:56:04 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2020-06-17 15:56:04 -0400
commit8f1b54ee608af86d448a9981257fa58727dfe6fc (patch)
tree4a05012e325a15d1269674c67f285fab21d81676
parent2741e9b381570f362732061dbca7835c8c185e9b (diff)
add "-V" version-message
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
-rw-r--r--man/twm.man10
-rw-r--r--src/twm.c20
2 files changed, 20 insertions, 10 deletions
diff --git a/man/twm.man b/man/twm.man
index 35ea30f..619ddaa 100644
--- a/man/twm.man
+++ b/man/twm.man
@@ -43,8 +43,11 @@
.SH NAME
twm \- Tab Window Manager for the X Window System
.SH SYNTAX
-\fBtwm \fP[ \fB\-display\fP \fIdpy\fP ] [ \fB\-s\fP ]
-[ \fB\-f\fP \fIinitfile\fP ] [ \fB\-v\fP ]
+\fBtwm \fP[ \fB\-display\fP \fIdpy\fP ]
+[ \fB\-s\fP ]
+[ \fB\-f\fP \fIinitfile\fP ]
+[ \fB\-v\fP ]
+[ \fB\-V\fP ]
.SH DESCRIPTION
\fITwm\fP is a window manager for the X Window System.
It provides
@@ -131,6 +134,9 @@ This option indicates that \fItwm\fP should print error messages whenever
an unexpected X Error event is received.
This can be useful when debugging
applications but can be distracting in regular use.
+.TP 8
+.B \-V
+Tell \fItwm\fP to print its version to the standard output, and exit.
.SH CUSTOMIZATION
Much of \fItwm\fP's appearance and behavior can be controlled by providing
a startup file in one of the following locations (searched in order for
diff --git a/src/twm.c b/src/twm.c
index a8d1c2f..a981ac4 100644
--- a/src/twm.c
+++ b/src/twm.c
@@ -75,6 +75,7 @@ in this Software without prior written authorization from The Open Group.
#include "screen.h"
#include "parse.h"
#include "session.h"
+#include "version.h"
#include <X11/Xproto.h>
#include <X11/Xatom.h>
#include <X11/SM/SMlib.h>
@@ -220,12 +221,12 @@ IsPrintScreen(Screen *s)
static void
usage(void)
{
- fprintf(stderr, "usage: %s [-display dpy] [-f file] [-s] [-q] [-v]"
+ fprintf(stderr, "usage: %s [-display dpy] [-f file] [-s] [-q] [-v] [-V]"
#ifdef XPRINT
" [-noprint]"
#endif /* XPRINT */
" [-clientId id] [-restore file]\n", ProgramName);
- exit(1);
+ exit(EXIT_FAILURE);
}
/***********************************************************************
@@ -258,6 +259,9 @@ main(int argc, char *argv[])
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
+ case 'V':
+ printf("%s %s\n", ProgramName, Version);
+ exit(EXIT_SUCCESS);
case 'd': /* -display dpy */
if (strcmp(&argv[i][1], "display"))
usage();
@@ -355,14 +359,14 @@ main(int argc, char *argv[])
NULL, 0, &zero, NULL))) {
fprintf(stderr, "%s: unable to open display \"%s\"\n",
ProgramName, XDisplayName(display_name));
- exit(1);
+ exit(EXIT_FAILURE);
}
if (fcntl(ConnectionNumber(dpy), F_SETFD, 1) == -1) {
fprintf(stderr,
"%s: unable to mark display connection as close-on-exec\n",
ProgramName);
- exit(1);
+ exit(EXIT_FAILURE);
}
if (restore_filename)
@@ -402,7 +406,7 @@ main(int argc, char *argv[])
fprintf(stderr,
"%s: Unable to allocate memory for screen list, exiting.\n",
ProgramName);
- exit(1);
+ exit(EXIT_FAILURE);
}
numManaged = 0;
PreviousScreen = DefaultScreen(dpy);
@@ -683,7 +687,7 @@ main(int argc, char *argv[])
if (MultiScreen && NumScreens > 0)
fprintf(stderr, "%s: unable to find any unmanaged %sscreens.\n",
ProgramName, NoPrintscreens ? "" : "video ");
- exit(1);
+ exit(EXIT_FAILURE);
}
(void) ConnectToSessionManager(client_id);
@@ -692,7 +696,7 @@ main(int argc, char *argv[])
HandlingEvents = TRUE;
InitEvents();
HandleEvents();
- exit(0);
+ exit(EXIT_SUCCESS);
}
/**
@@ -948,7 +952,7 @@ Done(XtPointer client_data _X_UNUSED, XtSignalId *si2 _X_UNUSED)
Reborder(CurrentTime);
XCloseDisplay(dpy);
}
- exit(0);
+ exit(EXIT_SUCCESS);
}
/*