summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tmux.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-07-20 15:50:04 +0000
committernicm <nicm@openbsd.org>2015-07-20 15:50:04 +0000
commit179ef39913a3f0e09f5a0f7919b7868c929f2fdf (patch)
treea250cceb2425cae35875f8a2c6574dcf73571f51 /usr.bin/tmux/tmux.c
parentVarious memory leaks upon error or unchecked allocations. (diff)
downloadwireguard-openbsd-179ef39913a3f0e09f5a0f7919b7868c929f2fdf.tar.xz
wireguard-openbsd-179ef39913a3f0e09f5a0f7919b7868c929f2fdf.zip
Add an option (history-file) for a file to save/restore command prompt
history, from Olof-Joachim Frahm.
Diffstat (limited to 'usr.bin/tmux/tmux.c')
-rw-r--r--usr.bin/tmux/tmux.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index b43295feb37..320abcb10aa 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.136 2015/06/04 20:34:22 jmc Exp $ */
+/* $OpenBSD: tmux.c,v 1.137 2015/07/20 15:50:04 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -198,10 +198,27 @@ shell_exec(const char *shell, const char *shellcmd)
fatal("execl failed");
}
+const char*
+find_home(void)
+{
+ struct passwd *pw;
+ const char *home;
+
+ home = getenv("HOME");
+ if (home == NULL || *home == '\0') {
+ pw = getpwuid(getuid());
+ if (pw != NULL)
+ home = pw->pw_dir;
+ else
+ home = NULL;
+ }
+
+ return home;
+}
+
int
main(int argc, char **argv)
{
- struct passwd *pw;
char *s, *path, *label, **var, tmp[PATH_MAX];
char in[256];
const char *home;
@@ -320,14 +337,7 @@ main(int argc, char **argv)
/* Locate the configuration file. */
if (cfg_file == NULL) {
- home = getenv("HOME");
- if (home == NULL || *home == '\0') {
- pw = getpwuid(getuid());
- if (pw != NULL)
- home = pw->pw_dir;
- else
- home = NULL;
- }
+ home = find_home();
if (home != NULL) {
xasprintf(&cfg_file, "%s/.tmux.conf", home);
if (access(cfg_file, R_OK) != 0 && errno == ENOENT) {