mirror of
https://github.com/tmux/tmux.git
synced 2025-09-06 19:38:21 +00:00
For the moment, restore if-shell and run-shell to parsing at the last
moment (when the shell command completes) rather than when first invoked, GitHub issue 2872.
This commit is contained in:
@@ -54,15 +54,15 @@ const struct cmd_entry cmd_run_shell_entry = {
|
||||
};
|
||||
|
||||
struct cmd_run_shell_data {
|
||||
struct client *client;
|
||||
char *cmd;
|
||||
struct cmd_list *cmdlist;
|
||||
char *cwd;
|
||||
struct cmdq_item *item;
|
||||
struct session *s;
|
||||
int wp_id;
|
||||
struct event timer;
|
||||
int flags;
|
||||
struct client *client;
|
||||
char *cmd;
|
||||
struct args_command_state *state;
|
||||
char *cwd;
|
||||
struct cmdq_item *item;
|
||||
struct session *s;
|
||||
int wp_id;
|
||||
struct event timer;
|
||||
int flags;
|
||||
};
|
||||
|
||||
static enum args_parse_type
|
||||
@@ -132,9 +132,8 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (cmd != NULL)
|
||||
cdata->cmd = format_single_from_target(item, cmd);
|
||||
} else {
|
||||
cdata->cmdlist = args_make_commands_now(self, item, 0, 1);
|
||||
if (cdata->cmdlist == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
cdata->state = args_make_commands_prepare(self, item, 0, NULL,
|
||||
wait, 1);
|
||||
}
|
||||
|
||||
if (args_has(args, 't') && wp != NULL)
|
||||
@@ -179,8 +178,10 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg)
|
||||
struct client *c = cdata->client;
|
||||
const char *cmd = cdata->cmd;
|
||||
struct cmdq_item *item = cdata->item, *new_item;
|
||||
struct cmd_list *cmdlist;
|
||||
char *error;
|
||||
|
||||
if (cdata->cmdlist == NULL && cmd != NULL) {
|
||||
if (cdata->state == NULL && cmd != NULL) {
|
||||
if (job_run(cmd, 0, NULL, cdata->s, cdata->cwd, NULL,
|
||||
cmd_run_shell_callback, cmd_run_shell_free, cdata,
|
||||
cdata->flags, -1, -1) == NULL)
|
||||
@@ -188,15 +189,20 @@ cmd_run_shell_timer(__unused int fd, __unused short events, void* arg)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cdata->cmdlist != NULL) {
|
||||
if (item == NULL) {
|
||||
new_item = cmdq_get_command(cdata->cmdlist, NULL);
|
||||
cmdq_append(c, new_item);
|
||||
} else {
|
||||
new_item = cmdq_get_command(cdata->cmdlist,
|
||||
cmdq_get_state(item));
|
||||
cmdq_insert_after(item, new_item);
|
||||
}
|
||||
cmdlist = args_make_commands(cdata->state, 0, NULL, &error);
|
||||
if (cmdlist == NULL) {
|
||||
if (cdata->item == NULL) {
|
||||
*error = toupper((u_char)*error);
|
||||
status_message_set(c, -1, 1, 0, "%s", error);
|
||||
} else
|
||||
cmdq_error(cdata->item, "%s", error);
|
||||
free(error);
|
||||
} else if (item == NULL) {
|
||||
new_item = cmdq_get_command(cmdlist, NULL);
|
||||
cmdq_append(c, new_item);
|
||||
} else {
|
||||
new_item = cmdq_get_command(cmdlist, cmdq_get_state(item));
|
||||
cmdq_insert_after(item, new_item);
|
||||
}
|
||||
|
||||
if (cdata->item != NULL)
|
||||
@@ -264,8 +270,8 @@ cmd_run_shell_free(void *data)
|
||||
session_remove_ref(cdata->s, __func__);
|
||||
if (cdata->client != NULL)
|
||||
server_client_unref(cdata->client);
|
||||
if (cdata->cmdlist != NULL)
|
||||
cmd_list_free(cdata->cmdlist);
|
||||
if (cdata->state != NULL)
|
||||
args_make_commands_free(cdata->state);
|
||||
free(cdata->cwd);
|
||||
free(cdata->cmd);
|
||||
free(cdata);
|
||||
|
Reference in New Issue
Block a user