summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-split-window.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2013-11-22 20:58:36 +0000
committernicm <nicm@openbsd.org>2013-11-22 20:58:36 +0000
commit8a115efd851119d08cf0660f40ea4c3cd733d223 (patch)
tree41b10404870f954617be48b34dca53acb60a1c49 /usr.bin/tmux/cmd-split-window.c
parentregen (diff)
downloadwireguard-openbsd-8a115efd851119d08cf0660f40ea4c3cd733d223.tar.xz
wireguard-openbsd-8a115efd851119d08cf0660f40ea4c3cd733d223.zip
Handle empty current directory more gracefully.
Diffstat (limited to 'usr.bin/tmux/cmd-split-window.c')
-rw-r--r--usr.bin/tmux/cmd-split-window.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c
index 024474f10a5..3266f16e26c 100644
--- a/usr.bin/tmux/cmd-split-window.c
+++ b/usr.bin/tmux/cmd-split-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-split-window.c,v 1.47 2013/10/10 12:28:38 nicm Exp $ */
+/* $OpenBSD: cmd-split-window.c,v 1.48 2013/11/22 20:58:36 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -95,13 +95,16 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
cp = format_expand(ft, args_get(args, 'c'));
format_free(ft);
- fd = open(cp, O_RDONLY|O_DIRECTORY);
- free(cp);
- if (fd == -1) {
- cmdq_error(cmdq, "bad working directory: %s",
- strerror(errno));
- return (CMD_RETURN_ERROR);
- }
+ if (cp != NULL && *cp != '\0') {
+ fd = open(cp, O_RDONLY|O_DIRECTORY);
+ free(cp);
+ if (fd == -1) {
+ cmdq_error(cmdq, "bad working directory: %s",
+ strerror(errno));
+ return (CMD_RETURN_ERROR);
+ }
+ } else if (cp != NULL)
+ free(cp);
cwd = fd;
} else if (cmdq->client != NULL && cmdq->client->session == NULL)
cwd = cmdq->client->cwd;