summaryrefslogtreecommitdiffstats
path: root/cmd-command-prompt.c
diff options
context:
space:
mode:
authornicm <nicm>2021-08-25 08:51:55 +0000
committernicm <nicm>2021-08-25 08:51:55 +0000
commit03d173cbd8e72c356512a0e19e356b07d518627a (patch)
tree3470ea9b0d06f58f84da38ba11c5bc9c015cb941 /cmd-command-prompt.c
parentc6d6af49039d7fc3ec14c2240153226709497313 (diff)
Validate command argument types (string or command list) and give more
useful error messages.
Diffstat (limited to 'cmd-command-prompt.c')
-rw-r--r--cmd-command-prompt.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c
index bca1a7fc..737c44c7 100644
--- a/cmd-command-prompt.c
+++ b/cmd-command-prompt.c
@@ -29,8 +29,10 @@
* Prompt for command in client.
*/
-static enum cmd_retval cmd_command_prompt_exec(struct cmd *,
- struct cmdq_item *);
+static enum args_parse_type cmd_command_prompt_args_parse(struct args *,
+ u_int, char **);
+static enum cmd_retval cmd_command_prompt_exec(struct cmd *,
+ struct cmdq_item *);
static int cmd_command_prompt_callback(struct client *, void *,
const char *, int);
@@ -40,7 +42,7 @@ const struct cmd_entry cmd_command_prompt_entry = {
.name = "command-prompt",
.alias = NULL,
- .args = { "1bFkiI:Np:t:T:", 0, 1, NULL },
+ .args = { "1bFkiI:Np:t:T:", 0, 1, cmd_command_prompt_args_parse },
.usage = "[-1bFkiN] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE
" [-T type] [template]",
@@ -68,6 +70,13 @@ struct cmd_command_prompt_cdata {
char **argv;
};
+static enum args_parse_type
+cmd_command_prompt_args_parse(__unused struct args *args, __unused u_int idx,
+ __unused char **cause)
+{
+ return (ARGS_PARSE_COMMANDS_OR_STRING);
+}
+
static enum cmd_retval
cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
{
@@ -197,8 +206,8 @@ cmd_command_prompt_callback(struct client *c, void *data, const char *s,
return (1);
out:
- if (item != NULL)
- cmdq_continue(item);
+ if (item != NULL)
+ cmdq_continue(item);
return (0);
}