summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tmux.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2020-01-28 10:44:30 +0000
committernicm <nicm@openbsd.org>2020-01-28 10:44:30 +0000
commit55bde1469dd533868ffb94045630288832b96a01 (patch)
treeab8fbfff92934e79ef65e6196762202efb9327dd /usr.bin/tmux/tmux.c
parentParse '==' without error in filters. (diff)
downloadwireguard-openbsd-55bde1469dd533868ffb94045630288832b96a01.tar.xz
wireguard-openbsd-55bde1469dd533868ffb94045630288832b96a01.zip
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 'usr.bin/tmux/tmux.c')
-rw-r--r--usr.bin/tmux/tmux.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index 3351e5a3c93..7351dae5756 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.190 2019/10/14 08:38:07 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.191 2020/01/28 10:44:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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;