diff --git a/client.c b/client.c index a7a6aafc..8395b78a 100644 --- a/client.c +++ b/client.c @@ -1,4 +1,4 @@ -/* $Id: client.c,v 1.62 2009-08-14 21:04:04 tcunha Exp $ */ +/* $Id: client.c,v 1.63 2009-08-14 21:23:20 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -123,7 +123,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 a2b144c5..2499140b 100644 --- a/server-msg.c +++ b/server-msg.c @@ -1,4 +1,4 @@ -/* $Id: server-msg.c,v 1.79 2009-08-14 21:17:54 tcunha Exp $ */ +/* $Id: server-msg.c,v 1.80 2009-08-14 21:23:20 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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) diff --git a/tmux.h b/tmux.h index a2a927bd..29717894 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.413 2009-08-14 21:20:01 tcunha Exp $ */ +/* $Id: tmux.h,v 1.414 2009-08-14 21:23:20 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1156,7 +1156,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 *); diff --git a/tty.c b/tty.c index 4c86585c..a63dcc4f 100644 --- a/tty.c +++ b/tty.c @@ -1,4 +1,4 @@ -/* $Id: tty.c,v 1.124 2009-08-14 21:20:01 tcunha Exp $ */ +/* $Id: tty.c,v 1.125 2009-08-14 21:23:20 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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) diff --git a/window.c b/window.c index 60cc4d54..3d680149 100644 --- a/window.c +++ b/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.100 2009-08-09 17:48:55 tcunha Exp $ */ +/* $Id: window.c,v 1.101 2009-08-14 21:23:20 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -59,18 +59,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