aboutsummaryrefslogtreecommitdiff
path: root/cmd-respawn-pane.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-respawn-pane.c')
-rw-r--r--cmd-respawn-pane.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/cmd-respawn-pane.c b/cmd-respawn-pane.c
index bcde2754..47031539 100644
--- a/cmd-respawn-pane.c
+++ b/cmd-respawn-pane.c
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $OpenBSD$ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -32,10 +32,9 @@ enum cmd_retval cmd_respawn_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_respawn_pane_entry = {
"respawn-pane", "respawnp",
- "kt:", 0, 1,
+ "kt:", 0, -1,
"[-k] " CMD_TARGET_PANE_USAGE " [command]",
0,
- NULL,
cmd_respawn_pane_exec
};
@@ -48,9 +47,10 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq)
struct window_pane *wp;
struct session *s;
struct environ env;
- const char *cmd;
+ const char *path;
char *cause;
u_int idx;
+ struct environ_entry *envent;
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
return (CMD_RETURN_ERROR);
@@ -73,11 +73,16 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq)
screen_reinit(&wp->base);
input_init(wp);
- if (args->argc != 0)
- cmd = args->argv[0];
+ path = NULL;
+ if (cmdq->client != NULL && cmdq->client->session == NULL)
+ envent = environ_find(&cmdq->client->environ, "PATH");
else
- cmd = NULL;
- if (window_pane_spawn(wp, cmd, NULL, -1, &env, s->tio, &cause) != 0) {
+ envent = environ_find(&s->environ, "PATH");
+ if (envent != NULL)
+ path = envent->value;
+
+ if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, -1, &env,
+ s->tio, &cause) != 0) {
cmdq_error(cmdq, "respawn pane failed: %s", cause);
free(cause);
environ_free(&env);