diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-11-22 20:58:37 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-11-22 20:58:37 +0000 |
commit | f45b9df3dc50eef15e5c5375152b0e8136d8e02b (patch) | |
tree | e719e1ea7f4c61d49be8f8e0818540f74f51d878 /usr.bin/tmux/cmd-new-session.c | |
parent | e993e60c872c97c85c8a785a0287b61cfbad4470 (diff) |
Handle empty current directory more gracefully.
Diffstat (limited to 'usr.bin/tmux/cmd-new-session.c')
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index dc5b7a88cfe..7ca7c01aea4 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.55 2013/10/10 12:28:38 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.56 2013/11/22 20:58:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -107,13 +107,16 @@ cmd_new_session_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 (c != NULL && c->session == NULL) cwd = c->cwd; |