mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 13:37:12 +00:00
Validate command argument types (string or command list) and give more
useful error messages.
This commit is contained in:
@ -29,7 +29,10 @@
|
||||
* Executes a tmux command if a shell command returns true or false.
|
||||
*/
|
||||
|
||||
static enum cmd_retval cmd_if_shell_exec(struct cmd *, struct cmdq_item *);
|
||||
static enum args_parse_type cmd_if_shell_args_parse(struct args *, u_int,
|
||||
char **);
|
||||
static enum cmd_retval cmd_if_shell_exec(struct cmd *,
|
||||
struct cmdq_item *);
|
||||
|
||||
static void cmd_if_shell_callback(struct job *);
|
||||
static void cmd_if_shell_free(void *);
|
||||
@ -38,7 +41,7 @@ const struct cmd_entry cmd_if_shell_entry = {
|
||||
.name = "if-shell",
|
||||
.alias = "if",
|
||||
|
||||
.args = { "bFt:", 2, 3, NULL },
|
||||
.args = { "bFt:", 2, 3, cmd_if_shell_args_parse },
|
||||
.usage = "[-bF] " CMD_TARGET_PANE_USAGE " shell-command command "
|
||||
"[command]",
|
||||
|
||||
@ -56,6 +59,15 @@ struct cmd_if_shell_data {
|
||||
struct cmdq_item *item;
|
||||
};
|
||||
|
||||
static enum args_parse_type
|
||||
cmd_if_shell_args_parse(__unused struct args *args, u_int idx,
|
||||
__unused char **cause)
|
||||
{
|
||||
if (idx == 1 || idx == 2)
|
||||
return (ARGS_PARSE_COMMANDS_OR_STRING);
|
||||
return (ARGS_PARSE_STRING);
|
||||
}
|
||||
|
||||
static enum cmd_retval
|
||||
cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
|
Reference in New Issue
Block a user