summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-new-session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-07-21 09:17:20 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-07-21 09:17:20 +0000
commit5e9fa049e1fa97f7add1fb4c0c012f9250f45fd5 (patch)
tree2d51a2108a8d36d8bde7d1edaecec79a7f98c68f /usr.bin/tmux/cmd-new-session.c
parent8b598ea6a71c4d88e29d28043a5a1c430f5edd89 (diff)
Add -c for respawn-pane and respawn-window, from J Raynor.
Diffstat (limited to 'usr.bin/tmux/cmd-new-session.c')
-rw-r--r--usr.bin/tmux/cmd-new-session.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c
index 44920b9cbeb..41c8553c0c3 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.107 2017/05/28 19:46:55 nicm Exp $ */
+/* $OpenBSD: cmd-new-session.c,v 1.108 2017/07/21 09:17:19 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -74,8 +74,8 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
struct termios tio, *tiop;
struct session_group *sg;
const char *newname, *errstr, *template, *group, *prefix;
- const char *path, *cmd, *cwd, *to_free = NULL;
- char **argv, *cause, *cp;
+ const char *path, *cmd, *cwd;
+ char **argv, *cause, *cp, *to_free = NULL;
int detached, already_attached, idx, argc;
int is_control = 0;
u_int sx, sy;
@@ -151,7 +151,8 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
/* Get the new session working directory. */
if (args_has(args, 'c')) {
cwd = args_get(args, 'c');
- to_free = cwd = format_single(item, cwd, c, NULL, NULL, NULL);
+ to_free = format_single(item, cwd, c, NULL, NULL, NULL);
+ cwd = to_free;
} else if (c != NULL && c->session == NULL && c->cwd != NULL)
cwd = c->cwd;
else
@@ -327,16 +328,13 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
cmd_find_from_session(&item->shared->current, s);
}
- if (to_free != NULL)
- free((void *)to_free);
-
cmd_find_from_session(&fs, s);
hooks_insert(s->hooks, item, &fs, "after-new-session");
+ free(to_free);
return (CMD_RETURN_NORMAL);
error:
- if (to_free != NULL)
- free((void *)to_free);
+ free(to_free);
return (CMD_RETURN_ERROR);
}