summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-detach-client.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-01-30 15:57:31 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-01-30 15:57:31 +0000
commit0afc3e6e67cbd8ecf3cf6702cc1d179fa66b7666 (patch)
tree6da346ecf1e1e9a5fe35a3e53b583fc45e810855 /usr.bin/tmux/cmd-detach-client.c
parentd593d487eb76ac0840cf4ffc325b2cfda720d873 (diff)
Tidy up detach-client a bit.
Diffstat (limited to 'usr.bin/tmux/cmd-detach-client.c')
-rw-r--r--usr.bin/tmux/cmd-detach-client.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/usr.bin/tmux/cmd-detach-client.c b/usr.bin/tmux/cmd-detach-client.c
index 0b5d7be0b7d..c07d9566ea0 100644
--- a/usr.bin/tmux/cmd-detach-client.c
+++ b/usr.bin/tmux/cmd-detach-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-detach-client.c,v 1.18 2014/10/20 23:01:51 nicm Exp $ */
+/* $OpenBSD: cmd-detach-client.c,v 1.19 2015/01/30 15:57:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -48,7 +48,7 @@ enum cmd_retval
cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
- struct client *c, *c2;
+ struct client *c, *cloop;
struct session *s;
enum msgtype msgtype;
u_int i;
@@ -73,32 +73,35 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session != s)
+ cloop = ARRAY_ITEM(&clients, i);
+ if (cloop == NULL || cloop->session != s)
continue;
- server_write_client(c, msgtype, c->session->name,
- strlen(c->session->name) + 1);
+ server_write_client(cloop, msgtype,
+ cloop->session->name,
+ strlen(cloop->session->name) + 1);
}
- } else {
- c = cmd_find_client(cmdq, args_get(args, 't'), 0);
- if (c == NULL)
- return (CMD_RETURN_ERROR);
+ return (CMD_RETURN_STOP);
+ }
- if (args_has(args, 'a')) {
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c2 = ARRAY_ITEM(&clients, i);
- if (c2 == NULL || c2->session == NULL ||
- c2 == c)
- continue;
- server_write_client(c2, msgtype,
- c2->session->name,
- strlen(c2->session->name) + 1);
- }
- } else {
- server_write_client(c, msgtype, c->session->name,
- strlen(c->session->name) + 1);
+ c = cmd_find_client(cmdq, args_get(args, 't'), 0);
+ if (c == NULL)
+ return (CMD_RETURN_ERROR);
+
+ if (args_has(args, 'a')) {
+ for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+ cloop = ARRAY_ITEM(&clients, i);
+ if (cloop == NULL || cloop->session == NULL)
+ continue;
+ if (cloop == c)
+ continue;
+ server_write_client(cloop, msgtype,
+ cloop->session->name,
+ strlen(cloop->session->name) + 1);
}
+ return (CMD_RETURN_NORMAL);
}
+ server_write_client(c, msgtype, c->session->name,
+ strlen(c->session->name) + 1);
return (CMD_RETURN_STOP);
}