=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-respawn-window.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- src/usr.bin/tmux/cmd-respawn-window.c 2013/10/10 12:29:53 1.20 +++ src/usr.bin/tmux/cmd-respawn-window.c 2014/04/17 13:02:59 1.21 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-respawn-window.c,v 1.20 2013/10/10 12:29:53 nicm Exp $ */ +/* $OpenBSD: cmd-respawn-window.c,v 1.21 2014/04/17 13:02:59 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -47,8 +47,9 @@ struct window_pane *wp; struct session *s; struct environ env; - const char *cmd; + const char *cmd, *path; char *cause; + struct environ_entry *envent; if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL) return (CMD_RETURN_ERROR); @@ -79,7 +80,17 @@ cmd = args->argv[0]; else cmd = NULL; - if (window_pane_spawn(wp, cmd, NULL, -1, &env, s->tio, &cause) != 0) { + + path = NULL; + if (cmdq->client != NULL && cmdq->client->session == NULL) + envent = environ_find(&cmdq->client->environ, "PATH"); + else + envent = environ_find(&s->environ, "PATH"); + if (envent != NULL) + path = envent->value; + + if (window_pane_spawn(wp, cmd, path, NULL, -1, &env, s->tio, + &cause) != 0) { cmdq_error(cmdq, "respawn window failed: %s", cause); free(cause); environ_free(&env);