=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/window.c,v retrieving revision 1.90 retrieving revision 1.91 diff -u -r1.90 -r1.91 --- src/usr.bin/tmux/window.c 2013/03/22 10:31:22 1.90 +++ src/usr.bin/tmux/window.c 2013/03/24 09:21:27 1.91 @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.90 2013/03/22 10:31:22 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.91 2013/03/24 09:21:27 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -310,24 +310,36 @@ struct window * window_create(const char *name, const char *cmd, const char *shell, const char *cwd, struct environ *env, struct termios *tio, - u_int sx, u_int sy, u_int hlimit,char **cause) + u_int sx, u_int sy, u_int hlimit, char **cause) { struct window *w; struct window_pane *wp; + const char *prefix; + char *cmd1; w = window_create1(sx, sy); wp = window_add_pane(w, hlimit); layout_init(w); - if (window_pane_spawn(wp, cmd, shell, cwd, env, tio, cause) != 0) { + + if (*cmd != '\0') { + prefix = options_get_string(&w->options, "command-prefix"); + xasprintf(&cmd1, "%s%s", prefix, cmd); + } else + cmd1 = xstrdup(""); + if (window_pane_spawn(wp, cmd1, shell, cwd, env, tio, cause) != 0) { window_destroy(w); + free(cmd1); return (NULL); } + free(cmd1); + w->active = TAILQ_FIRST(&w->panes); if (name != NULL) { w->name = xstrdup(name); options_set_number(&w->options, "automatic-rename", 0); } else w->name = default_window_name(w); + return (w); } @@ -703,6 +715,8 @@ free(wp->cwd); wp->cwd = xstrdup(cwd); } + + log_debug("spawn: %s -- %s", wp->shell, wp->cmd); memset(&ws, 0, sizeof ws); ws.ws_col = screen_size_x(&wp->base);