Expand argument to run-shell again.

This commit is contained in:
nicm 2021-09-09 13:38:32 +00:00
parent 5a4b2fd68c
commit 34312fd6ee
5 changed files with 10 additions and 9 deletions

View File

@ -651,13 +651,14 @@ args_string(struct args *args, u_int idx)
/* Make a command now. */ /* Make a command now. */
struct cmd_list * struct cmd_list *
args_make_commands_now(struct cmd *self, struct cmdq_item *item, u_int idx) args_make_commands_now(struct cmd *self, struct cmdq_item *item, u_int idx,
int expand)
{ {
struct args_command_state *state; struct args_command_state *state;
char *error; char *error;
struct cmd_list *cmdlist; struct cmd_list *cmdlist;
state = args_make_commands_prepare(self, item, idx, NULL, 0, 0); state = args_make_commands_prepare(self, item, idx, NULL, 0, expand);
cmdlist = args_make_commands(state, 0, NULL, &error); cmdlist = args_make_commands(state, 0, NULL, &error);
if (cmdlist == NULL) { if (cmdlist == NULL) {
cmdq_error(item, "%s", error); cmdq_error(item, "%s", error);

View File

@ -72,7 +72,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
int wait = !args_has(args, 'b'); int wait = !args_has(args, 'b');
cdata = xcalloc(1, sizeof *cdata); cdata = xcalloc(1, sizeof *cdata);
cdata->cmdlist = args_make_commands_now(self, item, 0); cdata->cmdlist = args_make_commands_now(self, item, 0, 0);
if (cdata->cmdlist == NULL) if (cdata->cmdlist == NULL)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);

View File

@ -84,9 +84,9 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
shellcmd = format_single_from_target(item, args_string(args, 0)); shellcmd = format_single_from_target(item, args_string(args, 0));
if (args_has(args, 'F')) { if (args_has(args, 'F')) {
if (*shellcmd != '0' && *shellcmd != '\0') if (*shellcmd != '0' && *shellcmd != '\0')
cmdlist = args_make_commands_now(self, item, 1); cmdlist = args_make_commands_now(self, item, 1, 0);
else if (count == 3) else if (count == 3)
cmdlist = args_make_commands_now(self, item, 2); cmdlist = args_make_commands_now(self, item, 2, 0);
else { else {
free(shellcmd); free(shellcmd);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
@ -101,11 +101,11 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
cdata = xcalloc(1, sizeof *cdata); cdata = xcalloc(1, sizeof *cdata);
cdata->cmd_if = args_make_commands_now(self, item, 1); cdata->cmd_if = args_make_commands_now(self, item, 1, 0);
if (cdata->cmd_if == NULL) if (cdata->cmd_if == NULL)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
if (count == 3) { if (count == 3) {
cdata->cmd_else = args_make_commands_now(self, item, 2); cdata->cmd_else = args_make_commands_now(self, item, 2, 0);
if (cdata->cmd_else == NULL) if (cdata->cmd_else == NULL)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }

View File

@ -132,7 +132,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
if (cmd != NULL) if (cmd != NULL)
cdata->cmd = format_single_from_target(item, cmd); cdata->cmd = format_single_from_target(item, cmd);
} else { } else {
cdata->cmdlist = args_make_commands_now(self, item, 0); cdata->cmdlist = args_make_commands_now(self, item, 0, 1);
if (cdata->cmdlist == NULL) if (cdata->cmdlist == NULL)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }

2
tmux.h
View File

@ -2234,7 +2234,7 @@ struct args_value *args_values(struct args *);
struct args_value *args_value(struct args *, u_int); struct args_value *args_value(struct args *, u_int);
const char *args_string(struct args *, u_int); const char *args_string(struct args *, u_int);
struct cmd_list *args_make_commands_now(struct cmd *, struct cmdq_item *, struct cmd_list *args_make_commands_now(struct cmd *, struct cmdq_item *,
u_int); u_int, int);
struct args_command_state *args_make_commands_prepare(struct cmd *, struct args_command_state *args_make_commands_prepare(struct cmd *,
struct cmdq_item *, u_int, const char *, int, int); struct cmdq_item *, u_int, const char *, int, int);
struct cmd_list *args_make_commands(struct args_command_state *, int, char **, struct cmd_list *args_make_commands(struct args_command_state *, int, char **,