mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Merge branch 'obsd-master'
This commit is contained in:
		@@ -73,14 +73,6 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
	struct session			*s = item->target.s;
 | 
			
		||||
	struct winlink			*wl = item->target.wl;
 | 
			
		||||
	struct window_pane		*wp = item->target.wp;
 | 
			
		||||
	const char			*cwd;
 | 
			
		||||
 | 
			
		||||
	if (item->client != NULL && item->client->session == NULL)
 | 
			
		||||
		cwd = item->client->cwd;
 | 
			
		||||
	else if (s != NULL)
 | 
			
		||||
		cwd = s->cwd;
 | 
			
		||||
	else
 | 
			
		||||
		cwd = NULL;
 | 
			
		||||
 | 
			
		||||
	shellcmd = format_single(item, args->argv[0], c, s, wl, wp);
 | 
			
		||||
	if (args_has(args, 'F')) {
 | 
			
		||||
@@ -128,8 +120,8 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
		cdata->item = NULL;
 | 
			
		||||
	memcpy(&cdata->mouse, &shared->mouse, sizeof cdata->mouse);
 | 
			
		||||
 | 
			
		||||
	job_run(shellcmd, s, cwd, NULL, cmd_if_shell_callback,
 | 
			
		||||
	    cmd_if_shell_free, cdata, 0);
 | 
			
		||||
	job_run(shellcmd, s, server_client_get_cwd(item->client, s), NULL,
 | 
			
		||||
	    cmd_if_shell_callback, cmd_if_shell_free, cdata, 0);
 | 
			
		||||
	free(shellcmd);
 | 
			
		||||
 | 
			
		||||
	if (args_has(args, 'b'))
 | 
			
		||||
 
 | 
			
		||||
@@ -156,10 +156,8 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
	/* Get the new session working directory. */
 | 
			
		||||
	if ((tmp = args_get(args, 'c')) != NULL)
 | 
			
		||||
		cwd = format_single(item, tmp, c, NULL, NULL, NULL);
 | 
			
		||||
	else if (c != NULL && c->session == NULL && c->cwd != NULL)
 | 
			
		||||
		cwd = xstrdup(c->cwd);
 | 
			
		||||
	else
 | 
			
		||||
		cwd = xstrdup(".");
 | 
			
		||||
		cwd = xstrdup(server_client_get_cwd(c, NULL));
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * If this is a new client, check for nesting and save the termios
 | 
			
		||||
 
 | 
			
		||||
@@ -95,10 +95,8 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
 | 
			
		||||
	if ((tmp = args_get(args, 'c')) != NULL)
 | 
			
		||||
		cwd = format_single(item, tmp, c, s, NULL, NULL);
 | 
			
		||||
	else if (item->client != NULL && item->client->session == NULL)
 | 
			
		||||
		cwd = xstrdup(item->client->cwd);
 | 
			
		||||
	else
 | 
			
		||||
		cwd = xstrdup(s->cwd);
 | 
			
		||||
		cwd = xstrdup(server_client_get_cwd(item->client, s));
 | 
			
		||||
 | 
			
		||||
	if ((tmp = args_get(args, 'n')) != NULL)
 | 
			
		||||
		name = format_single(item, tmp, c, s, NULL, NULL);
 | 
			
		||||
 
 | 
			
		||||
@@ -90,14 +90,6 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
	struct session			*s = item->target.s;
 | 
			
		||||
	struct winlink			*wl = item->target.wl;
 | 
			
		||||
	struct window_pane		*wp = item->target.wp;
 | 
			
		||||
	const char			*cwd;
 | 
			
		||||
 | 
			
		||||
	if (item->client != NULL && item->client->session == NULL)
 | 
			
		||||
		cwd = item->client->cwd;
 | 
			
		||||
	else if (s != NULL)
 | 
			
		||||
		cwd = s->cwd;
 | 
			
		||||
	else
 | 
			
		||||
		cwd = NULL;
 | 
			
		||||
 | 
			
		||||
	cdata = xcalloc(1, sizeof *cdata);
 | 
			
		||||
	cdata->cmd = format_single(item, args->argv[0], c, s, wl, wp);
 | 
			
		||||
@@ -110,8 +102,8 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
	if (!args_has(args, 'b'))
 | 
			
		||||
		cdata->item = item;
 | 
			
		||||
 | 
			
		||||
	job_run(cdata->cmd, s, cwd, NULL, cmd_run_shell_callback,
 | 
			
		||||
	    cmd_run_shell_free, cdata, 0);
 | 
			
		||||
	job_run(cdata->cmd, s, server_client_get_cwd(item->client, s), NULL,
 | 
			
		||||
	    cmd_run_shell_callback, cmd_run_shell_free, cdata, 0);
 | 
			
		||||
 | 
			
		||||
	if (args_has(args, 'b'))
 | 
			
		||||
		return (CMD_RETURN_NORMAL);
 | 
			
		||||
 
 | 
			
		||||
@@ -60,7 +60,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
	if (*path == '/')
 | 
			
		||||
		pattern = xstrdup(path);
 | 
			
		||||
	else {
 | 
			
		||||
		utf8_stravis(&tmp, server_client_get_cwd(c), VIS_GLOB);
 | 
			
		||||
		utf8_stravis(&tmp, server_client_get_cwd(c, NULL), VIS_GLOB);
 | 
			
		||||
		xasprintf(&pattern, "%s/%s", tmp, path);
 | 
			
		||||
		free(tmp);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -87,10 +87,8 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
 | 
			
		||||
 | 
			
		||||
	if ((tmp = args_get(args, 'c')) != NULL)
 | 
			
		||||
		cwd = format_single(item, tmp, c, s, NULL, NULL);
 | 
			
		||||
	else if (item->client != NULL && item->client->session == NULL)
 | 
			
		||||
		cwd = xstrdup(item->client->cwd);
 | 
			
		||||
	else
 | 
			
		||||
		cwd = xstrdup(s->cwd);
 | 
			
		||||
		cwd = xstrdup(server_client_get_cwd(item->client, s));
 | 
			
		||||
 | 
			
		||||
	type = LAYOUT_TOPBOTTOM;
 | 
			
		||||
	if (args_has(args, 'h'))
 | 
			
		||||
 
 | 
			
		||||
@@ -1861,15 +1861,19 @@ server_client_add_message(struct client *c, const char *fmt, ...)
 | 
			
		||||
 | 
			
		||||
/* Get client working directory. */
 | 
			
		||||
const char *
 | 
			
		||||
server_client_get_cwd(struct client *c)
 | 
			
		||||
server_client_get_cwd(struct client *c, struct session *s)
 | 
			
		||||
{
 | 
			
		||||
	struct session	*s;
 | 
			
		||||
	const char	*home;
 | 
			
		||||
 | 
			
		||||
	if (c != NULL && c->session == NULL && c->cwd != NULL)
 | 
			
		||||
		return (c->cwd);
 | 
			
		||||
	if (s != NULL && s->cwd != NULL)
 | 
			
		||||
		return (s->cwd);
 | 
			
		||||
	if (c != NULL && (s = c->session) != NULL && s->cwd != NULL)
 | 
			
		||||
		return (s->cwd);
 | 
			
		||||
	return (".");
 | 
			
		||||
	if ((home = find_home()) != NULL)
 | 
			
		||||
		return (home);
 | 
			
		||||
	return ("/");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Resolve an absolute path or relative to client working directory. */
 | 
			
		||||
@@ -1881,7 +1885,7 @@ server_client_get_path(struct client *c, const char *file)
 | 
			
		||||
	if (*file == '/')
 | 
			
		||||
		path = xstrdup(file);
 | 
			
		||||
	else
 | 
			
		||||
		xasprintf(&path, "%s/%s", server_client_get_cwd(c), file);
 | 
			
		||||
		xasprintf(&path, "%s/%s", server_client_get_cwd(c, NULL), file);
 | 
			
		||||
	if (realpath(path, resolved) == NULL)
 | 
			
		||||
		return (path);
 | 
			
		||||
	free(path);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1910,7 +1910,7 @@ void	 server_client_push_stderr(struct client *);
 | 
			
		||||
void printflike(2, 3) server_client_add_message(struct client *, const char *,
 | 
			
		||||
	     ...);
 | 
			
		||||
char	*server_client_get_path(struct client *, const char *);
 | 
			
		||||
const char *server_client_get_cwd(struct client *);
 | 
			
		||||
const char *server_client_get_cwd(struct client *, struct session *);
 | 
			
		||||
 | 
			
		||||
/* server-fn.c */
 | 
			
		||||
void	 server_redraw_client(struct client *);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								window.c
									
									
									
									
									
								
							@@ -922,7 +922,8 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv,
 | 
			
		||||
 | 
			
		||||
	cmd = cmd_stringify_argv(wp->argc, wp->argv);
 | 
			
		||||
	log_debug("%s: shell=%s", __func__, wp->shell);
 | 
			
		||||
	log_debug("%s: command=%s", __func__, cmd);
 | 
			
		||||
	log_debug("%s: cmd=%s", __func__, cmd);
 | 
			
		||||
	log_debug("%s: cwd=%s", __func__, cwd);
 | 
			
		||||
	for (i = 0; i < wp->argc; i++)
 | 
			
		||||
		log_debug("%s: argv[%d]=%s", __func__, i, wp->argv[i]);
 | 
			
		||||
	environ_log(env, "%s: environment ", __func__);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user