=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-detach-client.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- src/usr.bin/tmux/cmd-detach-client.c 2016/10/16 19:04:05 1.29 +++ src/usr.bin/tmux/cmd-detach-client.c 2017/01/13 10:12:12 1.30 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-detach-client.c,v 1.29 2016/10/16 19:04:05 nicm Exp $ */ +/* $OpenBSD: cmd-detach-client.c,v 1.30 2017/01/13 10:12:12 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -33,8 +33,9 @@ .name = "detach-client", .alias = "detach", - .args = { "as:t:P", 0, 0 }, - .usage = "[-P] [-a] [-s target-session] " CMD_TARGET_CLIENT_USAGE, + .args = { "aE:s:t:P", 0, 0 }, + .usage = "[-aP] [-E shell-command] " + "[-s target-session] " CMD_TARGET_CLIENT_USAGE, .sflag = CMD_SESSION, .tflag = CMD_CLIENT, @@ -63,6 +64,7 @@ struct client *c = item->state.c, *cloop; struct session *s; enum msgtype msgtype; + const char *cmd = args_get(args, 'E'); if (self->entry == &cmd_suspend_client_entry) { tty_stop_tty(&c->tty); @@ -79,20 +81,31 @@ if (args_has(args, 's')) { s = item->state.sflag.s; TAILQ_FOREACH(cloop, &clients, entry) { - if (cloop->session == s) - server_client_detach(cloop, msgtype); + if (cloop->session == s) { + if (cmd != NULL) + server_client_exec(cloop, cmd); + else + server_client_detach(cloop, msgtype); + } } return (CMD_RETURN_STOP); } if (args_has(args, 'a')) { TAILQ_FOREACH(cloop, &clients, entry) { - if (cloop->session != NULL && cloop != c) - server_client_detach(cloop, msgtype); + if (cloop->session != NULL && cloop != c) { + if (cmd != NULL) + server_client_exec(cloop, cmd); + else + server_client_detach(cloop, msgtype); + } } return (CMD_RETURN_NORMAL); } - server_client_detach(c, msgtype); + if (cmd != NULL) + server_client_exec(c, cmd); + else + server_client_detach(c, msgtype); return (CMD_RETURN_STOP); }