diff options
author | Thomas Adam <thomas@xteddy.org> | 2014-01-31 21:39:56 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2014-01-31 21:39:56 +0000 |
commit | d50e47fc4ab5cbbdbe6bbebdc2c36ce3aae6e987 (patch) | |
tree | 397f4999444c2eef367f884b815bec2a14697c3c /cmd-new-window.c | |
parent | cbf9224c5f7bcf07352f6ea128c90c12cb0af22e (diff) | |
parent | 9f02feb9d089b1a4639afb52ab0e8212eeb55a7c (diff) | |
download | rtmux-d50e47fc4ab5cbbdbe6bbebdc2c36ce3aae6e987.tar.gz rtmux-d50e47fc4ab5cbbdbe6bbebdc2c36ce3aae6e987.tar.bz2 rtmux-d50e47fc4ab5cbbdbe6bbebdc2c36ce3aae6e987.zip |
Merge branch 'obsd-master'
Conflicts:
Makefile
cmd-server-info.c
cmd-start-server.c
Diffstat (limited to 'cmd-new-window.c')
-rw-r--r-- | cmd-new-window.c | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/cmd-new-window.c b/cmd-new-window.c index 5c2cbe40..58a5eb65 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -82,26 +82,6 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq) } detached = args_has(args, 'd'); - wl = NULL; - if (idx != -1) - wl = winlink_find_by_index(&s->windows, idx); - if (wl != NULL && args_has(args, 'k')) { - /* - * Can't use session_detach as it will destroy session if this - * makes it empty. - */ - notify_window_unlinked(s, wl->window); - wl->flags &= ~WINLINK_ALERTFLAGS; - winlink_stack_remove(&s->lastw, wl); - winlink_remove(&s->windows, wl); - - /* Force select/redraw if current. */ - if (wl == s->curw) { - detached = 0; - s->curw = NULL; - } - } - if (args->argc == 0) cmd = options_get_string(&s->options, "default-command"); else @@ -117,19 +97,42 @@ 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; else cwd = s->cwd; + wl = NULL; + if (idx != -1) + wl = winlink_find_by_index(&s->windows, idx); + if (wl != NULL && args_has(args, 'k')) { + /* + * Can't use session_detach as it will destroy session if this + * makes it empty. + */ + notify_window_unlinked(s, wl->window); + wl->flags &= ~WINLINK_ALERTFLAGS; + winlink_stack_remove(&s->lastw, wl); + winlink_remove(&s->windows, wl); + + /* Force select/redraw if current. */ + if (wl == s->curw) { + detached = 0; + s->curw = NULL; + } + } + if (idx == -1) idx = -1 - options_get_number(&s->options, "base-index"); wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause); |