summaryrefslogtreecommitdiffstats
path: root/tmux.c
diff options
context:
space:
mode:
authornicm <nicm>2020-01-28 10:44:30 +0000
committernicm <nicm>2020-01-28 10:44:30 +0000
commitf165221dc4641837ee9f589bb666d310a495904c (patch)
tree803a9772a19610a93f444718119195863442b2b8 /tmux.c
parent32816eaebd4ccd712cc7f7291a587146d122a9ff (diff)
Reduce a difference with portable tmux by adding the -V flag and
#{version} format; on OpenBSD these just report the OpenBSD version.
Diffstat (limited to 'tmux.c')
-rw-r--r--tmux.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/tmux.c b/tmux.c
index fe2647f5..f98037b5 100644
--- a/tmux.c
+++ b/tmux.c
@@ -18,6 +18,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/utsname.h>
#include <err.h>
#include <errno.h>
@@ -212,6 +213,20 @@ find_home(void)
return (home);
}
+const char *
+getversion(void)
+{
+ static char *version;
+ struct utsname u;
+
+ if (version == NULL) {
+ if (uname(&u) < 0)
+ fatalx("uname failed");
+ xasprintf(&version, "openbsd-%s", u.release);
+ }
+ return version;
+}
+
int
main(int argc, char **argv)
{
@@ -238,7 +253,7 @@ main(int argc, char **argv)
flags = 0;
label = path = NULL;
- while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:uUv")) != -1) {
+ while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:uUvV")) != -1) {
switch (opt) {
case '2':
flags |= CLIENT_256COLOURS;
@@ -255,6 +270,9 @@ main(int argc, char **argv)
case 'f':
set_cfg_file(optarg);
break;
+ case 'V':
+ printf("%s %s\n", getprogname(), getversion());
+ exit(0);
case 'l':
flags |= CLIENT_LOGIN;
break;