mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	If forking a login shell or if SHELL is otherwise not useful, set it to the
default shell. Based on a diff from martynas@.
This commit is contained in:
		
							
								
								
									
										6
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								window.c
									
									
									
									
									
								
							@@ -512,6 +512,11 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
 | 
				
			|||||||
		log_close();
 | 
							log_close();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (*wp->cmd != '\0') {
 | 
							if (*wp->cmd != '\0') {
 | 
				
			||||||
 | 
								/* Set SHELL but only if it is currently not useful. */
 | 
				
			||||||
 | 
								shell = getenv("SHELL");
 | 
				
			||||||
 | 
								if (shell == NULL || *shell == '\0' || areshell(shell))
 | 
				
			||||||
 | 
									setenv("SHELL", wp->shell, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			execl(_PATH_BSHELL, "sh", "-c", wp->cmd, (char *) NULL);
 | 
								execl(_PATH_BSHELL, "sh", "-c", wp->cmd, (char *) NULL);
 | 
				
			||||||
			fatal("execl failed");
 | 
								fatal("execl failed");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -522,6 +527,7 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
 | 
				
			|||||||
			xasprintf(&argv0, "-%s", ptr + 1);
 | 
								xasprintf(&argv0, "-%s", ptr + 1);
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			xasprintf(&argv0, "-%s", wp->shell);
 | 
								xasprintf(&argv0, "-%s", wp->shell);
 | 
				
			||||||
 | 
							setenv("SHELL", wp->shell, 1);
 | 
				
			||||||
		execl(wp->shell, argv0, (char *) NULL);
 | 
							execl(wp->shell, argv0, (char *) NULL);
 | 
				
			||||||
		fatal("execl failed");
 | 
							fatal("execl failed");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user