summaryrefslogtreecommitdiffstats
path: root/cmd-display-message.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2013-03-25 11:42:01 +0000
committerNicholas Marriott <nicm@openbsd.org>2013-03-25 11:42:01 +0000
commit0c969a7dfd7800ea3f86216069d99a03befbdda4 (patch)
tree528460dbaccdab09d64612c1c1301db30f6a457c /cmd-display-message.c
parent111d993e75e869cb487302faf4319e1f4a02e8f8 (diff)
Handle no client better in display-message.
Diffstat (limited to 'cmd-display-message.c')
-rw-r--r--cmd-display-message.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/cmd-display-message.c b/cmd-display-message.c
index 7f31d7e2..52d47a4c 100644
--- a/cmd-display-message.c
+++ b/cmd-display-message.c
@@ -70,6 +70,18 @@ cmd_display_message_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
}
+ if (args_has(args, 'c')) {
+ c = cmd_find_client(cmdq, args_get(args, 'c'), 0);
+ if (c == NULL)
+ return (CMD_RETURN_ERROR);
+ } else {
+ c = cmd_current_client(cmdq);
+ if (c == NULL && !args_has(self->args, 'p')) {
+ cmdq_error(cmdq, "no client available");
+ return (CMD_RETURN_ERROR);
+ }
+ }
+
template = args_get(args, 'F');
if (args->argc != 0)
template = args->argv[0];
@@ -77,7 +89,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_q *cmdq)
template = DISPLAY_MESSAGE_TEMPLATE;
ft = format_create();
- if ((c = cmd_find_client(cmdq, args_get(args, 'c'), 1)) != NULL)
+ if (c != NULL)
format_client(ft, c);
format_session(ft, s);
format_winlink(ft, s, wl);