summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2013-03-25 11:42:02 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2013-03-25 11:42:02 +0000
commitb27ff0b14fcd52e2057d95650f742638288db2c0 (patch)
tree5ba3f8f0f0f8417385f318d51627211bdbe29fa2 /usr.bin/tmux
parent94dba0ba8ecf815161c9576287d715a917f0161b (diff)
Handle no client better in display-message.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/cmd-display-message.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-display-message.c b/usr.bin/tmux/cmd-display-message.c
index 173c794df38..7609373c840 100644
--- a/usr.bin/tmux/cmd-display-message.c
+++ b/usr.bin/tmux/cmd-display-message.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-display-message.c,v 1.21 2013/03/25 11:41:31 nicm Exp $ */
+/* $OpenBSD: cmd-display-message.c,v 1.22 2013/03/25 11:42:01 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -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);
@@ -90,10 +102,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_q *cmdq)
msg = format_expand(ft, out);
if (args_has(self->args, 'p'))
cmdq_print(cmdq, "%s", msg);
- else if (c == NULL) {
- cmdq_error(cmdq, "no client available");
- return (CMD_RETURN_ERROR);
- } else
+ else
status_message_set(c, "%s", msg);
free(msg);
format_free(ft);