mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Just appending -l to $SHELL to create a login shell is wrong: -l is not POSIX,
and some people may use shells which do not support it. Instead, make an empty default-command option mean a login shell, and fork it with a - in argv[0] which is the method used by login(1). Also fix the automatic-rename code to handle this correctly and to strip a leading - if present.
This commit is contained in:
		
							
								
								
									
										15
									
								
								names.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								names.c
									
									
									
									
									
								
							@@ -59,7 +59,16 @@ set_window_names(void)
 | 
			
		||||
		if (name == NULL)
 | 
			
		||||
			wname = default_window_name(w);
 | 
			
		||||
		else {
 | 
			
		||||
			wname = parse_window_name(name);
 | 
			
		||||
			/* 
 | 
			
		||||
			 * If tmux is using the default command, it will be a
 | 
			
		||||
			 * login shell and argv[0] may have a - prefix. Remove
 | 
			
		||||
			 * this if it is present. Ick.
 | 
			
		||||
			 */
 | 
			
		||||
			if (w->active->cmd != NULL && *w->active->cmd == '\0' &&
 | 
			
		||||
			    name != NULL && name[0] == '-' && name[1] != '\0')
 | 
			
		||||
				wname = parse_window_name(name + 1);
 | 
			
		||||
			else
 | 
			
		||||
				wname = parse_window_name(name);
 | 
			
		||||
			xfree(name);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -78,7 +87,9 @@ default_window_name(struct window *w)
 | 
			
		||||
{
 | 
			
		||||
	if (w->active->screen != &w->active->base)
 | 
			
		||||
		return (xstrdup("[tmux]"));
 | 
			
		||||
	return (parse_window_name(w->active->cmd));
 | 
			
		||||
	if (w->active->cmd != NULL && *w->active->cmd != '\0')
 | 
			
		||||
		return (parse_window_name(w->active->cmd));
 | 
			
		||||
	return (parse_window_name(window_default_command()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user