aboutsummaryrefslogtreecommitdiff
path: root/cmd-set-hook.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2018-07-04 15:02:25 +0100
committerThomas Adam <thomas@xteddy.org>2018-07-04 15:02:25 +0100
commit20154f391ea0821d4e58ce952b69e08a33209b74 (patch)
treec4dc2791ead38feeb455d5279ecdbe31f5d0862c /cmd-set-hook.c
parent5c0ce192ed313c988f7d67e4911ef602a894cea0 (diff)
parent98c4291df2201271a0d70fc141cfaf744021ff35 (diff)
downloadrtmux-20154f391ea0821d4e58ce952b69e08a33209b74.tar.gz
rtmux-20154f391ea0821d4e58ce952b69e08a33209b74.tar.bz2
rtmux-20154f391ea0821d4e58ce952b69e08a33209b74.zip
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-set-hook.c')
-rw-r--r--cmd-set-hook.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/cmd-set-hook.c b/cmd-set-hook.c
index d0cd98db..b04e6335 100644
--- a/cmd-set-hook.c
+++ b/cmd-set-hook.c
@@ -33,8 +33,8 @@ const struct cmd_entry cmd_set_hook_entry = {
.name = "set-hook",
.alias = NULL,
- .args = { "gt:u", 1, 2 },
- .usage = "[-gu] " CMD_TARGET_SESSION_USAGE " hook-name [command]",
+ .args = { "gRt:u", 1, 2 },
+ .usage = "[-gRu] " CMD_TARGET_SESSION_USAGE " hook-name [command]",
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
@@ -101,18 +101,21 @@ cmd_set_hook_exec(struct cmd *self, struct cmdq_item *item)
else
cmd = args->argv[1];
+ if (cmd != NULL && (args_has(args, 'R') || args_has(args, 'u'))) {
+ cmdq_error(item, "no command allowed");
+ return (CMD_RETURN_ERROR);
+ }
+ if (args_has(args, 'R')) {
+ notify_hook(item, name);
+ return (CMD_RETURN_NORMAL);
+ }
if (args_has(args, 'u')) {
- if (cmd != NULL) {
- cmdq_error(item, "command passed to unset hook: %s",
- name);
- return (CMD_RETURN_ERROR);
- }
hooks_remove(hooks, name);
return (CMD_RETURN_NORMAL);
}
if (cmd == NULL) {
- cmdq_error(item, "no command to set hook: %s", name);
+ cmdq_error(item, "no command given");
return (CMD_RETURN_ERROR);
}
cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);