diff options
Diffstat (limited to 'cmd-new-window.c')
-rw-r--r-- | cmd-new-window.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/cmd-new-window.c b/cmd-new-window.c index e2a01190..354d0ae5 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -117,13 +117,16 @@ cmd_new_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; |