mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Some code tidying.
This commit is contained in:
parent
c7394ac4e0
commit
a910b38a35
@ -114,6 +114,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
{
|
{
|
||||||
struct cmd_new_session_data *data = self->data;
|
struct cmd_new_session_data *data = self->data;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
|
struct window *w;
|
||||||
struct environ env;
|
struct environ env;
|
||||||
struct termios tio;
|
struct termios tio;
|
||||||
const char *update;
|
const char *update;
|
||||||
@ -186,29 +187,31 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find new session size and options. */
|
/* Get the new session working directory. */
|
||||||
|
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||||
|
cwd = ctx->cmdclient->cwd;
|
||||||
|
else
|
||||||
|
cwd = options_get_string(&global_s_options, "default-path");
|
||||||
|
|
||||||
|
/* Find new session size. */
|
||||||
if (detached) {
|
if (detached) {
|
||||||
sx = 80;
|
sx = 80;
|
||||||
sy = 25;
|
sy = 25;
|
||||||
} else {
|
} else if (ctx->cmdclient != NULL) {
|
||||||
if (ctx->cmdclient != NULL) {
|
|
||||||
sx = ctx->cmdclient->tty.sx;
|
sx = ctx->cmdclient->tty.sx;
|
||||||
sy = ctx->cmdclient->tty.sy;
|
sy = ctx->cmdclient->tty.sy;
|
||||||
} else {
|
} else {
|
||||||
sx = ctx->curclient->tty.sx;
|
sx = ctx->curclient->tty.sx;
|
||||||
sy = ctx->curclient->tty.sy;
|
sy = ctx->curclient->tty.sy;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (sy > 0 && options_get_number(&global_s_options, "status"))
|
if (sy > 0 && options_get_number(&global_s_options, "status"))
|
||||||
sy--;
|
sy--;
|
||||||
if (sx == 0)
|
if (sx == 0)
|
||||||
sx = 1;
|
sx = 1;
|
||||||
if (sy == 0)
|
if (sy == 0)
|
||||||
sy = 1;
|
sy = 1;
|
||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
|
||||||
cwd = ctx->cmdclient->cwd;
|
/* Figure out the command for the new window. */
|
||||||
else
|
|
||||||
cwd = options_get_string(&global_s_options, "default-path");
|
|
||||||
if (data->cmd != NULL)
|
if (data->cmd != NULL)
|
||||||
cmd = data->cmd;
|
cmd = data->cmd;
|
||||||
else
|
else
|
||||||
@ -231,26 +234,23 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
|
|
||||||
|
/* Set the initial window name if one given. */
|
||||||
if (data->winname != NULL) {
|
if (data->winname != NULL) {
|
||||||
xfree(s->curw->window->name);
|
w = s->curw->window;
|
||||||
s->curw->window->name = xstrdup(data->winname);
|
|
||||||
options_set_number(
|
xfree(w->name);
|
||||||
&s->curw->window->options, "automatic-rename", 0);
|
w->name = xstrdup(data->winname);
|
||||||
|
|
||||||
|
options_set_number(&w->options, "automatic-rename", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If a command client exists, it is either taking this session (and
|
* Set the client to the new session. If a command client exists, it is
|
||||||
* needs to get MSG_READY and stay around), or -d is given and it needs
|
* taking this session and needs to get MSG_READY and stay around.
|
||||||
* to exit.
|
|
||||||
*/
|
*/
|
||||||
if (ctx->cmdclient != NULL) {
|
|
||||||
if (!detached)
|
|
||||||
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the client to the new session. */
|
|
||||||
if (!detached) {
|
if (!detached) {
|
||||||
if (ctx->cmdclient != NULL) {
|
if (ctx->cmdclient != NULL) {
|
||||||
|
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
|
||||||
ctx->cmdclient->session = s;
|
ctx->cmdclient->session = s;
|
||||||
server_redraw_client(ctx->cmdclient);
|
server_redraw_client(ctx->cmdclient);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user