summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-01-30 19:08:48 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-01-30 19:08:48 +0000
commit8fa996c0b7c0e6f90fe86e7009aaad907b3012f1 (patch)
tree046b61a08054b66f65c56db62851ed782328732a /usr.bin/tmux
parent004204998c18d170698ed39f29c809f86903d161 (diff)
Don't stop parsing command sequences when a command requests the client to
stick around (attach-session/new-session).
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/cmd-list.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/usr.bin/tmux/cmd-list.c b/usr.bin/tmux/cmd-list.c
index 6054ac53ae6..6705285df86 100644
--- a/usr.bin/tmux/cmd-list.c
+++ b/usr.bin/tmux/cmd-list.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list.c,v 1.2 2009/07/26 12:58:44 nicm Exp $ */
+/* $OpenBSD: cmd-list.c,v 1.3 2010/01/30 19:08:47 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -77,13 +77,32 @@ int
cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
{
struct cmd *cmd;
- int n;
+ int n, retval;
+ retval = 0;
TAILQ_FOREACH(cmd, cmdlist, qentry) {
- if ((n = cmd_exec(cmd, ctx)) != 0)
- return (n);
+ if ((n = cmd_exec(cmd, ctx)) == -1)
+ return (-1);
+
+ /*
+ * A 1 return value means the command client is being attached
+ * (sent MSG_READY).
+ */
+ if (n == 1) {
+ retval = 1;
+
+ /*
+ * The command client has been attached, so mangle the
+ * context to treat any following commands as if they
+ * were called from inside.
+ */
+ if (ctx->curclient == NULL) {
+ ctx->curclient = ctx->cmdclient;
+ ctx->cmdclient = NULL;
+ }
+ }
}
- return (0);
+ return (retval);
}
void