summaryrefslogtreecommitdiffstats
path: root/cmd-split-window.c
diff options
context:
space:
mode:
authornicm <nicm>2014-05-13 08:08:32 +0000
committernicm <nicm>2014-05-13 08:08:32 +0000
commitb3e8d440ed0477e88232c3ba1779c67eafce3a48 (patch)
tree09e92eb59a30d393132b4da6d8cc3d3623f755b2 /cmd-split-window.c
parentb1a06ef22e54e943d733db8dcc98fe60051c93de (diff)
If multiple arguments are given to new-session, new-window,
split-window, respawn-window or respawn-pane, pass them directly to execvp() to help avoid quoting problems. One argument still goes to "sh -c" like before. Requested by many over the years. Patch from J Raynor.
Diffstat (limited to 'cmd-split-window.c')
-rw-r--r--cmd-split-window.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 50949b39..55231134 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -36,7 +36,7 @@ enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_split_window_entry = {
"split-window", "splitw",
- "c:dF:l:hp:Pt:v", 0, 1,
+ "c:dF:l:hp:Pt:v", 0, -1,
"[-dhvP] [-c start-directory] [-F format] [-p percentage|-l size] "
CMD_TARGET_PANE_USAGE " [command]",
0,
@@ -62,9 +62,9 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
struct window_pane *wp, *new_wp = NULL;
struct environ env;
const char *cmd, *path, *shell, *template;
- char *cause, *new_cause, *cp;
+ char **argv, *cause, *new_cause, *cp;
u_int hlimit;
- int size, percentage, cwd, fd = -1;
+ int argc, size, percentage, cwd, fd = -1;
enum layout_type type;
struct layout_cell *lc;
struct client *c;
@@ -81,10 +81,19 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
environ_copy(&s->environ, &env);
server_fill_environ(s, &env);
- if (args->argc == 0)
+ if (args->argc == 0) {
cmd = options_get_string(&s->options, "default-command");
- else
- cmd = args->argv[0];
+ if (cmd != NULL && *cmd != '\0') {
+ argc = 1;
+ argv = (char**)&cmd;
+ } else {
+ argc = 0;
+ argv = NULL;
+ }
+ } else {
+ argc = args->argc;
+ argv = args->argv;
+ }
if (args_has(args, 'c')) {
ft = format_create();
@@ -158,8 +167,8 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
if (envent != NULL)
path = envent->value;
- if (window_pane_spawn(
- new_wp, cmd, path, shell, cwd, &env, s->tio, &cause) != 0)
+ if (window_pane_spawn(new_wp, argc, argv, path, shell, cwd, &env,
+ s->tio, &cause) != 0)
goto error;
layout_assign_pane(lc, new_wp);