mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Prefer PWD for current directory if present in client, from Wei Zhao in
GitHub issue 1183.
This commit is contained in:
		
							
								
								
									
										8
									
								
								client.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								client.c
									
									
									
									
									
								
							| @@ -279,10 +279,10 @@ client_main(struct event_base *base, int argc, char **argv, int flags) | |||||||
| 	client_peer = proc_add_peer(client_proc, fd, client_dispatch, NULL); | 	client_peer = proc_add_peer(client_proc, fd, client_dispatch, NULL); | ||||||
|  |  | ||||||
| 	/* Save these before pledge(). */ | 	/* Save these before pledge(). */ | ||||||
| 	if ((cwd = getcwd(path, sizeof path)) == NULL) { | 	if ((cwd = getenv("PWD")) == NULL && | ||||||
| 		if ((cwd = find_home()) == NULL) | 	    (cwd = getcwd(path, sizeof path)) == NULL && | ||||||
| 			cwd = "/"; | 	    (cwd = find_home()) == NULL) | ||||||
| 	} | 		cwd = "/"; | ||||||
| 	if ((ttynam = ttyname(STDIN_FILENO)) == NULL) | 	if ((ttynam = ttyname(STDIN_FILENO)) == NULL) | ||||||
| 		ttynam = ""; | 		ttynam = ""; | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										7
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								tmux.c
									
									
									
									
									
								
							| @@ -193,7 +193,7 @@ main(int argc, char **argv) | |||||||
| { | { | ||||||
| 	char					*path, *label, **var; | 	char					*path, *label, **var; | ||||||
| 	char					 tmp[PATH_MAX]; | 	char					 tmp[PATH_MAX]; | ||||||
| 	const char				*s, *shell; | 	const char				*s, *shell, *cwd; | ||||||
| 	int					 opt, flags, keys; | 	int					 opt, flags, keys; | ||||||
| 	const struct options_table_entry	*oe; | 	const struct options_table_entry	*oe; | ||||||
|  |  | ||||||
| @@ -294,8 +294,9 @@ main(int argc, char **argv) | |||||||
| 	global_environ = environ_create(); | 	global_environ = environ_create(); | ||||||
| 	for (var = environ; *var != NULL; var++) | 	for (var = environ; *var != NULL; var++) | ||||||
| 		environ_put(global_environ, *var); | 		environ_put(global_environ, *var); | ||||||
| 	if (getcwd(tmp, sizeof tmp) != NULL) | 	if ((cwd = getenv("PWD")) == NULL && | ||||||
| 		environ_set(global_environ, "PWD", "%s", tmp); | 	    (cwd = getcwd(tmp, sizeof tmp)) != NULL) | ||||||
|  | 		environ_set(global_environ, "PWD", "%s", cwd); | ||||||
|  |  | ||||||
| 	global_options = options_create(NULL); | 	global_options = options_create(NULL); | ||||||
| 	global_s_options = options_create(NULL); | 	global_s_options = options_create(NULL); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 nicm
					nicm