aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2016-05-12 16:01:10 +0100
committerThomas Adam <thomas@xteddy.org>2016-05-12 16:01:10 +0100
commit3ec7e3c006d3eb86547b5a1b47dd8d873d7b0284 (patch)
tree5b433bcdddc2d7d69c8633dfa6b38c49975b7c0a
parente76d44a64081ea1ea325b23266ad60a24448d9ab (diff)
parent9715c61de0d7891cfe584ae1f63904a50abc2a54 (diff)
downloadrtmux-3ec7e3c006d3eb86547b5a1b47dd8d873d7b0284.tar.gz
rtmux-3ec7e3c006d3eb86547b5a1b47dd8d873d7b0284.tar.bz2
rtmux-3ec7e3c006d3eb86547b5a1b47dd8d873d7b0284.zip
Merge branch 'obsd-master'
-rw-r--r--cmd-set-hook.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/cmd-set-hook.c b/cmd-set-hook.c
index 8ef02f8c..4d7cf908 100644
--- a/cmd-set-hook.c
+++ b/cmd-set-hook.c
@@ -36,7 +36,7 @@ const struct cmd_entry cmd_set_hook_entry = {
.args = { "gt:u", 1, 2 },
.usage = "[-gu] " CMD_TARGET_SESSION_USAGE " hook-name [command]",
- .tflag = CMD_SESSION,
+ .tflag = CMD_SESSION_CANFAIL,
.flags = 0,
.exec = cmd_set_hook_exec
@@ -63,12 +63,21 @@ cmd_set_hook_exec(struct cmd *self, struct cmd_q *cmdq)
struct hooks *hooks;
struct hook *hook;
char *cause, *tmp;
- const char *name, *cmd;
+ const char *name, *cmd, *target;
if (args_has(args, 'g'))
hooks = global_hooks;
- else
+ else {
+ if (cmdq->state.tflag.s == NULL) {
+ target = args_get(args, 't');
+ if (target != NULL)
+ cmdq_error(cmdq, "no such session: %s", target);
+ else
+ cmdq_error(cmdq, "no current session");
+ return (CMD_RETURN_ERROR);
+ }
hooks = cmdq->state.tflag.s->hooks;
+ }
if (self->entry == &cmd_show_hooks_entry) {
hook = hooks_first(hooks);