version 1.125, 2020/04/13 08:26:27 |
version 1.126, 2020/04/13 10:59:58 |
|
|
cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) |
cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
struct args *args = cmd_get_args(self); |
struct args *args = cmd_get_args(self); |
struct client *c = item->client; |
struct cmdq_shared *shared = cmdq_get_shared(item); |
|
struct cmd_find_state *current = &shared->current; |
|
struct cmd_find_state *target = cmdq_get_target(item); |
|
struct client *c = cmdq_get_client(item); |
struct session *s, *as, *groupwith; |
struct session *s, *as, *groupwith; |
struct environ *env; |
struct environ *env; |
struct options *oo; |
struct options *oo; |
|
|
if (newname != NULL) |
if (newname != NULL) |
as = session_find(newname); |
as = session_find(newname); |
else |
else |
as = item->target.s; |
as = target->s; |
if (as != NULL) { |
if (as != NULL) { |
retval = cmd_attach_session(item, as->name, |
retval = cmd_attach_session(item, as->name, |
args_has(args, 'D'), args_has(args, 'X'), 0, NULL, |
args_has(args, 'D'), args_has(args, 'X'), 0, NULL, |
|
|
/* Is this going to be part of a session group? */ |
/* Is this going to be part of a session group? */ |
group = args_get(args, 't'); |
group = args_get(args, 't'); |
if (group != NULL) { |
if (group != NULL) { |
groupwith = item->target.s; |
groupwith = target->s; |
if (groupwith == NULL) { |
if (groupwith == NULL) { |
if (!session_check_name(group)) { |
if (!session_check_name(group)) { |
cmdq_error(item, "bad group name: %s", group); |
cmdq_error(item, "bad group name: %s", group); |
|
|
* over. |
* over. |
*/ |
*/ |
if (!detached && !already_attached && c->tty.fd != -1) { |
if (!detached && !already_attached && c->tty.fd != -1) { |
if (server_client_check_nested(item->client)) { |
if (server_client_check_nested(cmdq_get_client(item))) { |
cmdq_error(item, "sessions should be nested with care, " |
cmdq_error(item, "sessions should be nested with care, " |
"unset $TMUX to force"); |
"unset $TMUX to force"); |
goto fail; |
goto fail; |
|
|
} else if (c->session != NULL) |
} else if (c->session != NULL) |
c->last_session = c->session; |
c->last_session = c->session; |
c->session = s; |
c->session = s; |
if (~item->shared->flags & CMDQ_SHARED_REPEAT) |
if (~shared->flags & CMDQ_SHARED_REPEAT) |
server_client_set_key_table(c, NULL); |
server_client_set_key_table(c, NULL); |
tty_update_client_offset(c); |
tty_update_client_offset(c); |
status_timer_start(c); |
status_timer_start(c); |
|
|
|
|
if (!detached) { |
if (!detached) { |
c->flags |= CLIENT_ATTACHED; |
c->flags |= CLIENT_ATTACHED; |
cmd_find_from_session(&item->shared->current, s, 0); |
cmd_find_from_session(current, s, 0); |
} |
} |
|
|
cmd_find_from_session(&fs, s, 0); |
cmd_find_from_session(&fs, s, 0); |