diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2016-05-13 08:32:46 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2016-05-13 08:32:46 +0100 |
commit | 2377092a70db3327cbeb07328ea8422d0395edc4 (patch) | |
tree | c5ede8c90856cf9ded1a0d62e62fe1089d580ef3 /cmd-set-hook.c | |
parent | af25cab11b4dc17d3c1a7c2c2cf6e40b8f2b3ae9 (diff) | |
parent | 6cb74f4b7dad1e21f2fb0714c7fe83a85bf92a2c (diff) | |
download | rtmux-2377092a70db3327cbeb07328ea8422d0395edc4.tar.gz rtmux-2377092a70db3327cbeb07328ea8422d0395edc4.tar.bz2 rtmux-2377092a70db3327cbeb07328ea8422d0395edc4.zip |
Merge branch 'master' of github.com:tmux/tmux
Diffstat (limited to 'cmd-set-hook.c')
-rw-r--r-- | cmd-set-hook.c | 15 |
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); |