mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Don't stop parsing command sequences when a command requests the client to
stick around (attach-session/new-session).
This commit is contained in:
		
							
								
								
									
										27
									
								
								cmd-list.c
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								cmd-list.c
									
									
									
									
									
								
							@@ -77,13 +77,32 @@ int
 | 
				
			|||||||
cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
 | 
					cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cmd	*cmd;
 | 
						struct cmd	*cmd;
 | 
				
			||||||
	int		 n;
 | 
						int		 n, retval;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						retval = 0;
 | 
				
			||||||
	TAILQ_FOREACH(cmd, cmdlist, qentry) {
 | 
						TAILQ_FOREACH(cmd, cmdlist, qentry) {
 | 
				
			||||||
		if ((n = cmd_exec(cmd, ctx)) != 0)
 | 
							if ((n = cmd_exec(cmd, ctx)) == -1)
 | 
				
			||||||
			return (n);
 | 
								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
 | 
					void
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user