=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-new-window.c,v retrieving revision 1.38 retrieving revision 1.39 diff -c -r1.38 -r1.39 *** src/usr.bin/tmux/cmd-new-window.c 2013/11/23 09:18:29 1.38 --- src/usr.bin/tmux/cmd-new-window.c 2014/04/17 13:02:59 1.39 *************** *** 1,4 **** ! /* $OpenBSD: cmd-new-window.c,v 1.38 2013/11/23 09:18:29 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: cmd-new-window.c,v 1.39 2014/04/17 13:02:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 49,58 **** struct session *s; struct winlink *wl; struct client *c; ! const char *cmd, *template; char *cause, *cp; int idx, last, detached, cwd, fd = -1; struct format_tree *ft; if (args_has(args, 'a')) { wl = cmd_find_window(cmdq, args_get(args, 't'), &s); --- 49,59 ---- struct session *s; struct winlink *wl; struct client *c; ! const char *cmd, *path, *template; char *cause, *cp; int idx, last, detached, cwd, fd = -1; struct format_tree *ft; + struct environ_entry *envent; if (args_has(args, 'a')) { wl = cmd_find_window(cmdq, args_get(args, 't'), &s); *************** *** 77,83 **** server_unlink_window(s, wl); } } else { ! if ((idx = cmd_find_index(cmdq, args_get(args, 't'), &s)) == -2) return (CMD_RETURN_ERROR); } detached = args_has(args, 'd'); --- 78,85 ---- server_unlink_window(s, wl); } } else { ! idx = cmd_find_index(cmdq, args_get(args, 't'), &s); ! if (idx == -2) return (CMD_RETURN_ERROR); } detached = args_has(args, 'd'); *************** *** 87,92 **** --- 89,102 ---- else cmd = args->argv[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 (args_has(args, 'c')) { ft = format_create(); if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL) *************** *** 135,141 **** if (idx == -1) idx = -1 - options_get_number(&s->options, "base-index"); ! wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause); if (wl == NULL) { cmdq_error(cmdq, "create window failed: %s", cause); free(cause); --- 145,151 ---- if (idx == -1) idx = -1 - options_get_number(&s->options, "base-index"); ! wl = session_new(s, args_get(args, 'n'), cmd, path, cwd, idx, &cause); if (wl == NULL) { cmdq_error(cmdq, "create window failed: %s", cause); free(cause);