mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	If getcwd() fails, use the user's home directory, or /, instead of failing with
an error.
This commit is contained in:
		
							
								
								
									
										7
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								tmux.c
									
									
									
									
									
								
							@@ -371,8 +371,11 @@ main(int argc, char **argv)
 | 
			
		||||
	    &global_options, "default-command", "exec %s -l", shell);
 | 
			
		||||
 | 
			
		||||
	if (getcwd(cwd, sizeof cwd) == NULL) {
 | 
			
		||||
		log_warn("getcwd");
 | 
			
		||||
		exit(1);
 | 
			
		||||
		pw = getpwuid(getuid());
 | 
			
		||||
		if (pw->pw_dir != NULL && *pw->pw_dir != '\0')
 | 
			
		||||
			strlcpy(cwd, pw->pw_dir, sizeof cwd);
 | 
			
		||||
		else
 | 
			
		||||
			strlcpy(cwd, "/", sizeof cwd);
 | 
			
		||||
	}
 | 
			
		||||
	options_set_string(&global_options, "default-path", "%s", cwd);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user