diff options
author | 2019-04-28 20:05:50 +0000 | |
---|---|---|
committer | 2019-04-28 20:05:50 +0000 | |
commit | d0772b58724ed55a3cf536d835c40b0be4672eb7 (patch) | |
tree | 4be7102055e890cc6477cf05d1d5155b34d0188f /usr.bin/tmux/cmd-split-window.c | |
parent | Fix reading route entries via kvm(3). (diff) | |
download | wireguard-openbsd-d0772b58724ed55a3cf536d835c40b0be4672eb7.tar.xz wireguard-openbsd-d0772b58724ed55a3cf536d835c40b0be4672eb7.zip |
Support multiple occurances of the same argument. Use this for a new
flag -e to new-window, split-window, respawn-window, respawn-pane to
pass environment variables into the newly created process. From Steffen
Christgau in GitHub issue 1697.
Diffstat (limited to 'usr.bin/tmux/cmd-split-window.c')
-rw-r--r-- | usr.bin/tmux/cmd-split-window.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c index 65473c36446..25ee7bd1a69 100644 --- a/usr.bin/tmux/cmd-split-window.c +++ b/usr.bin/tmux/cmd-split-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-split-window.c,v 1.93 2019/04/26 11:38:51 nicm Exp $ */ +/* $OpenBSD: cmd-split-window.c,v 1.94 2019/04/28 20:05:50 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -40,8 +40,8 @@ const struct cmd_entry cmd_split_window_entry = { .name = "split-window", .alias = "splitw", - .args = { "bc:dfF:l:hp:Pt:v", 0, -1 }, - .usage = "[-bdfhvP] [-c start-directory] [-F format] " + .args = { "bc:de:fF:l:hp:Pt:v", 0, -1 }, + .usage = "[-bdefhvP] [-c start-directory] [-e environment] [-F format] " "[-p percentage|-l size] " CMD_TARGET_PANE_USAGE " [command]", .target = { 't', CMD_FIND_PANE, 0 }, @@ -64,8 +64,9 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item) struct layout_cell *lc; struct cmd_find_state fs; int size, percentage, flags; - const char *template; + const char *template, *add; char *cause, *cp; + struct args_value *value; if (args_has(args, 'h')) type = LAYOUT_LEFTRIGHT; @@ -117,6 +118,13 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item) sc.name = NULL; sc.argc = args->argc; sc.argv = args->argv; + sc.environ = environ_create(); + + add = args_first_value(args, 'e', &value); + while (add != NULL) { + environ_put(sc.environ, add); + add = args_next_value(&value); + } sc.idx = -1; sc.cwd = args_get(args, 'c'); @@ -146,5 +154,6 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item) cmd_find_from_winlink_pane(&fs, wl, new_wp, 0); cmdq_insert_hook(s, item, &fs, "after-split-window"); + environ_free(sc.environ); return (CMD_RETURN_NORMAL); } |