summaryrefslogtreecommitdiffstats
path: root/cmd-split-window.c
diff options
context:
space:
mode:
authornicm <nicm>2018-03-01 12:53:08 +0000
committernicm <nicm>2018-03-01 12:53:08 +0000
commit182357f24bc7e16d7d7c85cab0c61974f18df2e7 (patch)
treeaaf97a0274f043e226f216c83f5dfd25db518e98 /cmd-split-window.c
parent508e2f0b3aaf2db9b692863738e7ca75765fc70c (diff)
Expand formats in window and session names.
Diffstat (limited to 'cmd-split-window.c')
-rw-r--r--cmd-split-window.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 8d47e350..b75eaa6f 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -61,8 +61,8 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
struct window *w = wl->window;
struct window_pane *wp = item->target.wp, *new_wp = NULL;
struct environ *env;
- const char *cmd, *path, *shell, *template, *cwd;
- char **argv, *cause, *new_cause, *cp, *to_free = NULL;
+ const char *cmd, *path, *shell, *template, *tmp;
+ char **argv, *cause, *new_cause, *cp, *cwd;
u_int hlimit;
int argc, size, percentage;
enum layout_type type;
@@ -86,14 +86,12 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
argv = args->argv;
}
- if (args_has(args, 'c')) {
- cwd = args_get(args, 'c');
- to_free = format_single(item, cwd, c, s, NULL, NULL);
- cwd = to_free;
- } else if (item->client != NULL && item->client->session == NULL)
- cwd = item->client->cwd;
+ if ((tmp = args_get(args, 'c')) != NULL)
+ cwd = format_single(item, tmp, c, s, NULL, NULL);
+ else if (item->client != NULL && item->client->session == NULL)
+ cwd = xstrdup(item->client->cwd);
else
- cwd = s->cwd;
+ cwd = xstrdup(s->cwd);
type = LAYOUT_TOPBOTTOM;
if (args_has(args, 'h'))
@@ -175,7 +173,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
cmd_find_from_winlink_pane(&fs, wl, new_wp, 0);
hooks_insert(s->hooks, item, &fs, "after-split-window");
- free(to_free);
+ free(cwd);
return (CMD_RETURN_NORMAL);
error:
@@ -186,6 +184,6 @@ error:
cmdq_error(item, "create pane failed: %s", cause);
free(cause);
- free(to_free);
+ free(cwd);
return (CMD_RETURN_ERROR);
}