summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-if-shell.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2020-04-13 15:55:51 +0000
committernicm <nicm@openbsd.org>2020-04-13 15:55:51 +0000
commitc1e0bdab59c04d8d0d3ef52aa8a6170ae05c8104 (patch)
tree2c67551e92d2cdfd3a50152e674b2e70e1d37da7 /usr.bin/tmux/cmd-if-shell.c
parentMove cmdq_state into cmd-queue.c. (diff)
downloadwireguard-openbsd-c1e0bdab59c04d8d0d3ef52aa8a6170ae05c8104.tar.xz
wireguard-openbsd-c1e0bdab59c04d8d0d3ef52aa8a6170ae05c8104.zip
When adding a list of commands to the queue, instead of automatically
creating a new state for each group of commands, require the caller to create one and use it for all the commands in the list. This means the current target works even with list with multiple groups (which can happen if they are defined with newlines).
Diffstat (limited to 'usr.bin/tmux/cmd-if-shell.c')
-rw-r--r--usr.bin/tmux/cmd-if-shell.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/usr.bin/tmux/cmd-if-shell.c b/usr.bin/tmux/cmd-if-shell.c
index 50075cc3f6d..e2956ab260d 100644
--- a/usr.bin/tmux/cmd-if-shell.c
+++ b/usr.bin/tmux/cmd-if-shell.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-if-shell.c,v 1.71 2020/04/13 14:46:04 nicm Exp $ */
+/* $OpenBSD: cmd-if-shell.c,v 1.72 2020/04/13 15:55:51 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -56,7 +56,6 @@ struct cmd_if_shell_data {
struct client *client;
struct cmdq_item *item;
- struct key_event event;
};
static enum cmd_retval
@@ -64,7 +63,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
- struct key_event *event = cmdq_get_event(item);
+ struct cmdq_state *state = cmdq_get_state(item);
struct cmd_if_shell_data *cdata;
char *shellcmd, *cmd;
const char *file;
@@ -101,8 +100,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
free(pr->error);
return (CMD_RETURN_ERROR);
case CMD_PARSE_SUCCESS:
- new_item = cmdq_get_command(pr->cmdlist, target, event,
- 0);
+ new_item = cmdq_get_command(pr->cmdlist, state);
cmdq_insert_after(item, new_item);
cmd_list_free(pr->cmdlist);
break;
@@ -117,7 +115,6 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
cdata->cmd_else = xstrdup(args->argv[2]);
else
cdata->cmd_else = NULL;
- memcpy(&cdata->event, event, sizeof cdata->event);
if (!args_has(args, 'b'))
cdata->client = cmdq_get_client(item);
@@ -161,8 +158,8 @@ cmd_if_shell_callback(struct job *job)
{
struct cmd_if_shell_data *cdata = job_get_data(job);
struct client *c = cdata->client;
- struct key_event *event = &cdata->event;
struct cmdq_item *new_item = NULL;
+ struct cmdq_state *new_state = NULL;
char *cmd;
int status;
struct cmd_parse_result *pr;
@@ -185,7 +182,13 @@ cmd_if_shell_callback(struct job *job)
free(pr->error);
break;
case CMD_PARSE_SUCCESS:
- new_item = cmdq_get_command(pr->cmdlist, NULL, event, 0);
+ if (cdata->item == NULL)
+ new_state = cmdq_new_state(NULL, NULL, 0);
+ else
+ new_state = cmdq_get_state(cdata->item);
+ new_item = cmdq_get_command(pr->cmdlist, new_state);
+ if (cdata->item == NULL)
+ cmdq_free_state(new_state);
cmd_list_free(pr->cmdlist);
break;
}