diff options
-rw-r--r-- | client.c | 3 | ||||
-rw-r--r-- | server-msg.c | 8 | ||||
-rw-r--r-- | tmux.h | 2 | ||||
-rw-r--r-- | tty.c | 14 | ||||
-rw-r--r-- | window.c | 19 |
5 files changed, 31 insertions, 15 deletions
@@ -119,7 +119,8 @@ server_started: if (strlcpy(data.tty, name, sizeof data.tty) >= sizeof data.tty) fatalx("ttyname failed"); - client_write_server(cctx, MSG_IDENTIFY, &data, sizeof data); + imsg_compose(&cctx->ibuf, MSG_IDENTIFY, + PROTOCOL_VERSION, -1, STDIN_FILENO, &data, sizeof data); } return (0); diff --git a/server-msg.c b/server-msg.c index 3e82f90a..286e8bdc 100644 --- a/server-msg.c +++ b/server-msg.c @@ -27,7 +27,7 @@ #include "tmux.h" void server_msg_command(struct client *, struct msg_command_data *); -void server_msg_identify(struct client *, struct msg_identify_data *); +void server_msg_identify(struct client *, struct msg_identify_data *, int); void server_msg_resize(struct client *, struct msg_resize_data *); void printflike2 server_msg_command_error(struct cmd_ctx *, const char *, ...); @@ -76,7 +76,7 @@ server_msg_dispatch(struct client *c) fatalx("bad MSG_IDENTIFY size"); memcpy(&identifydata, imsg.data, sizeof identifydata); - server_msg_identify(c, &identifydata); + server_msg_identify(c, &identifydata, imsg.fd); break; case MSG_RESIZE: if (datalen != sizeof resizedata) @@ -235,7 +235,7 @@ error: } void -server_msg_identify(struct client *c, struct msg_identify_data *data) +server_msg_identify(struct client *c, struct msg_identify_data *data, int fd) { c->tty.sx = data->sx; c->tty.sy = data->sy; @@ -247,7 +247,7 @@ server_msg_identify(struct client *c, struct msg_identify_data *data) data->tty[(sizeof data->tty) - 1] = '\0'; data->term[(sizeof data->term) - 1] = '\0'; - tty_init(&c->tty, data->tty, data->term); + tty_init(&c->tty, fd, data->tty, data->term); if (data->flags & IDENTIFY_UTF8) c->tty.flags |= TTY_UTF8; if (data->flags & IDENTIFY_256COLOURS) @@ -1158,7 +1158,7 @@ void tty_putcode2(struct tty *, enum tty_code_code, int, int); void tty_puts(struct tty *, const char *); void tty_putc(struct tty *, u_char); void tty_pututf8(struct tty *, const struct grid_utf8 *); -void tty_init(struct tty *, char *, char *); +void tty_init(struct tty *, int, char *, char *); void tty_start_tty(struct tty *); void tty_stop_tty(struct tty *); void tty_detect_utf8(struct tty *); @@ -45,9 +45,11 @@ void tty_cell(struct tty *, const struct grid_cell *, const struct grid_utf8 *); void -tty_init(struct tty *tty, char *path, char *term) +tty_init(struct tty *tty, int fd, char *path, char *term) { tty->path = xstrdup(path); + tty->fd = fd; + if (term == NULL || *term == '\0') tty->termname = xstrdup("unknown"); else @@ -59,12 +61,14 @@ tty_init(struct tty *tty, char *path, char *term) int tty_open(struct tty *tty, const char *overrides, char **cause) { - int mode; + int mode; - tty->fd = open(tty->path, O_RDWR|O_NONBLOCK); if (tty->fd == -1) { - xasprintf(cause, "%s: %s", tty->path, strerror(errno)); - return (-1); + tty->fd = open(tty->path, O_RDWR|O_NONBLOCK); + if (tty->fd == -1) { + xasprintf(cause, "%s: %s", tty->path, strerror(errno)); + return (-1); + } } if ((mode = fcntl(tty->fd, F_GETFL)) == -1) @@ -61,18 +61,29 @@ RB_GENERATE(winlinks, winlink, entry, winlink_cmp); const char * window_default_command(void) { - const char *shell; + const char *shell, *ptr; struct passwd *pw; shell = getenv("SHELL"); if (shell != NULL && *shell != '\0') - return (shell); + goto found; pw = getpwuid(getuid()); - if (pw != NULL && pw->pw_shell != NULL && *pw->pw_shell != '\0') - return (pw->pw_shell); + if (pw != NULL && pw->pw_shell != NULL && *pw->pw_shell != '\0') { + shell = pw->pw_shell; + goto found; + } return (_PATH_BSHELL); + +found: + if ((ptr = strrchr(shell, '/')) != NULL) + ptr++; + else + ptr = shell; + if (strcmp(ptr, __progname) == 0) + return (_PATH_BSHELL); + return (shell); } int |