summaryrefslogtreecommitdiffstats
path: root/cmd-run-shell.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-run-shell.c
parentc6d6af49039d7fc3ec14c2240153226709497313 (diff)
Validate command argument types (string or command list) and give more
useful error messages.
Diffstat (limited to 'cmd-run-shell.c')
-rw-r--r--cmd-run-shell.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/cmd-run-shell.c b/cmd-run-shell.c
index f23a8ec3..662312fb 100644
--- a/cmd-run-shell.c
+++ b/cmd-run-shell.c
@@ -30,7 +30,10 @@
* Runs a command without a window.
*/
-static enum cmd_retval cmd_run_shell_exec(struct cmd *, struct cmdq_item *);
+static enum args_parse_type cmd_run_shell_args_parse(struct args *, u_int,
+ char **);
+static enum cmd_retval cmd_run_shell_exec(struct cmd *,
+ struct cmdq_item *);
static void cmd_run_shell_timer(int, short, void *);
static void cmd_run_shell_callback(struct job *);
@@ -41,7 +44,7 @@ const struct cmd_entry cmd_run_shell_entry = {
.name = "run-shell",
.alias = "run",
- .args = { "bd:Ct:", 0, 1, NULL },
+ .args = { "bd:Ct:", 0, 1, cmd_run_shell_args_parse },
.usage = "[-bC] [-d delay] " CMD_TARGET_PANE_USAGE " [shell-command]",
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
@@ -62,6 +65,15 @@ struct cmd_run_shell_data {
int flags;
};
+static enum args_parse_type
+cmd_run_shell_args_parse(struct args *args, __unused u_int idx,
+ __unused char **cause)
+{
+ if (args_has(args, 'C'))
+ return (ARGS_PARSE_COMMANDS_OR_STRING);
+ return (ARGS_PARSE_STRING);
+}
+
static void
cmd_run_shell_print(struct job *job, const char *msg)
{