=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-run-shell.c,v retrieving revision 1.79 retrieving revision 1.80 diff -c -r1.79 -r1.80 *** src/usr.bin/tmux/cmd-run-shell.c 2021/09/09 13:38:32 1.79 --- src/usr.bin/tmux/cmd-run-shell.c 2021/09/15 07:38:30 1.80 *************** *** 1,4 **** ! /* $OpenBSD: cmd-run-shell.c,v 1.79 2021/09/09 13:38:32 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha --- 1,4 ---- ! /* $OpenBSD: cmd-run-shell.c,v 1.80 2021/09/15 07:38:30 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha *************** *** 54,68 **** }; 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; }; static enum args_parse_type --- 54,68 ---- }; struct cmd_run_shell_data { ! 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,140 **** 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); } if (args_has(args, 't') && wp != NULL) --- 132,139 ---- if (cmd != NULL) cdata->cmd = format_single_from_target(item, cmd); } else { ! cdata->state = args_make_commands_prepare(self, item, 0, NULL, ! wait, 1); } if (args_has(args, 't') && wp != NULL) *************** *** 179,186 **** struct client *c = cdata->client; const char *cmd = cdata->cmd; struct cmdq_item *item = cdata->item, *new_item; ! if (cdata->cmdlist == 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) --- 178,187 ---- 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->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,202 **** 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); ! } } if (cdata->item != NULL) --- 189,208 ---- return; } ! 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,271 **** session_remove_ref(cdata->s, __func__); if (cdata->client != NULL) server_client_unref(cdata->client); ! if (cdata->cmdlist != NULL) ! cmd_list_free(cdata->cmdlist); free(cdata->cwd); free(cdata->cmd); free(cdata); --- 270,277 ---- session_remove_ref(cdata->s, __func__); if (cdata->client != NULL) server_client_unref(cdata->client); ! if (cdata->state != NULL) ! args_make_commands_free(cdata->state); free(cdata->cwd); free(cdata->cmd); free(cdata);