summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-detach-client.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-04-22 10:22:40 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-04-22 10:22:40 +0000
commit3b5031a1e691e18e1bbe892b262d81db17887237 (patch)
tree280122dc6016981c484998db1ba10afbfdadb998 /usr.bin/tmux/cmd-detach-client.c
parent61be04363b84fafcbfe17c4d58547b1ca814e2c7 (diff)
Get rid of the extra layer of flags and cmd_prepare() and just store the
CMD_FIND_* flags in the cmd_entry and call it for the command. Commands with special requirements call it themselves and update the target for hooks to use.
Diffstat (limited to 'usr.bin/tmux/cmd-detach-client.c')
-rw-r--r--usr.bin/tmux/cmd-detach-client.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/tmux/cmd-detach-client.c b/usr.bin/tmux/cmd-detach-client.c
index 7db1d489b32..025050e5a75 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.31 2017/04/19 14:00:28 nicm Exp $ */
+/* $OpenBSD: cmd-detach-client.c,v 1.32 2017/04/22 10:22:39 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -37,8 +37,7 @@ const struct cmd_entry cmd_detach_client_entry = {
.usage = "[-aP] [-E shell-command] "
"[-s target-session] " CMD_TARGET_CLIENT_USAGE,
- .sflag = CMD_SESSION,
- .tflag = CMD_CLIENT,
+ .source = { 's', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
.flags = CMD_READONLY,
.exec = cmd_detach_client_exec
@@ -51,8 +50,6 @@ const struct cmd_entry cmd_suspend_client_entry = {
.args = { "t:", 0, 0 },
.usage = CMD_TARGET_CLIENT_USAGE,
- .tflag = CMD_CLIENT,
-
.flags = 0,
.exec = cmd_detach_client_exec
};
@@ -61,11 +58,14 @@ static enum cmd_retval
cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
- struct client *c = item->state.c, *cloop;
+ struct client *c, *cloop;
struct session *s;
enum msgtype msgtype;
const char *cmd = args_get(args, 'E');
+ if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
+ return (CMD_RETURN_ERROR);
+
if (self->entry == &cmd_suspend_client_entry) {
server_client_suspend(c);
return (CMD_RETURN_NORMAL);
@@ -77,7 +77,9 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item)
msgtype = MSG_DETACH;
if (args_has(args, 's')) {
- s = item->state.sflag.s;
+ s = item->source.s;
+ if (s == NULL)
+ return (CMD_RETURN_NORMAL);
TAILQ_FOREACH(cloop, &clients, entry) {
if (cloop->session == s) {
if (cmd != NULL)