mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Make command exec functions return an enum rather than -1/0/1 values and
add a new value to mean "leave client running but don't attach" to fix problems with using some commands in a command sequence. Most of the work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
This commit is contained in:
		
							
								
								
									
										18
									
								
								cfg.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								cfg.c
									
									
									
									
									
								
							@@ -81,7 +81,7 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
 | 
			
		||||
	size_t		 len;
 | 
			
		||||
	struct cmd_list	*cmdlist;
 | 
			
		||||
	struct cmd_ctx	 ctx;
 | 
			
		||||
	int		 retval;
 | 
			
		||||
	enum cmd_retval	 retval;
 | 
			
		||||
 | 
			
		||||
	if ((f = fopen(path, "rb")) == NULL) {
 | 
			
		||||
		cfg_add_cause(causes, "%s: %s", path, strerror(errno));
 | 
			
		||||
@@ -90,7 +90,7 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
 | 
			
		||||
	n = 0;
 | 
			
		||||
 | 
			
		||||
	line = NULL;
 | 
			
		||||
	retval = 0;
 | 
			
		||||
	retval = CMD_RETURN_NORMAL;
 | 
			
		||||
	while ((buf = fgetln(f, &len))) {
 | 
			
		||||
		if (buf[len - 1] == '\n')
 | 
			
		||||
			len--;
 | 
			
		||||
@@ -145,8 +145,18 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
 | 
			
		||||
		ctx.info = cfg_print;
 | 
			
		||||
 | 
			
		||||
		cfg_cause = NULL;
 | 
			
		||||
		if (cmd_list_exec(cmdlist, &ctx) == 1)
 | 
			
		||||
			retval = 1;
 | 
			
		||||
		switch (cmd_list_exec(cmdlist, &ctx)) {
 | 
			
		||||
		case CMD_RETURN_YIELD:
 | 
			
		||||
			if (retval != CMD_RETURN_ATTACH)
 | 
			
		||||
				retval = CMD_RETURN_YIELD;
 | 
			
		||||
			break;
 | 
			
		||||
		case CMD_RETURN_ATTACH:
 | 
			
		||||
			retval = CMD_RETURN_ATTACH;
 | 
			
		||||
			break;
 | 
			
		||||
		case CMD_RETURN_ERROR:
 | 
			
		||||
		case CMD_RETURN_NORMAL:
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		cmd_list_free(cmdlist);
 | 
			
		||||
		if (cfg_cause != NULL) {
 | 
			
		||||
			cfg_add_cause(
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user