mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Make shell_command a global like other stuff rather than making it an
exception and using callback argument.
This commit is contained in:
		
							
								
								
									
										18
									
								
								client.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								client.c
									
									
									
									
									
								
							@@ -64,7 +64,7 @@ static void		 client_write(int, const char *, size_t);
 | 
			
		||||
static void		 client_signal(int);
 | 
			
		||||
static void		 client_dispatch(struct imsg *, void *);
 | 
			
		||||
static void		 client_dispatch_attached(struct imsg *);
 | 
			
		||||
static void		 client_dispatch_wait(struct imsg *, const char *);
 | 
			
		||||
static void		 client_dispatch_wait(struct imsg *);
 | 
			
		||||
static const char	*client_exit_message(void);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@@ -215,8 +215,7 @@ client_exit_message(void)
 | 
			
		||||
 | 
			
		||||
/* Client main loop. */
 | 
			
		||||
int
 | 
			
		||||
client_main(struct event_base *base, int argc, char **argv, int flags,
 | 
			
		||||
    const char *shellcmd)
 | 
			
		||||
client_main(struct event_base *base, int argc, char **argv, int flags)
 | 
			
		||||
{
 | 
			
		||||
	struct cmd		*cmd;
 | 
			
		||||
	struct cmd_list		*cmdlist;
 | 
			
		||||
@@ -237,7 +236,7 @@ client_main(struct event_base *base, int argc, char **argv, int flags,
 | 
			
		||||
 | 
			
		||||
	/* Set up the initial command. */
 | 
			
		||||
	cmdflags = 0;
 | 
			
		||||
	if (shellcmd != NULL) {
 | 
			
		||||
	if (shell_command != NULL) {
 | 
			
		||||
		msg = MSG_SHELL;
 | 
			
		||||
		cmdflags = CMD_STARTSERVER;
 | 
			
		||||
	} else if (argc == 0) {
 | 
			
		||||
@@ -276,8 +275,7 @@ client_main(struct event_base *base, int argc, char **argv, int flags,
 | 
			
		||||
		}
 | 
			
		||||
		return (1);
 | 
			
		||||
	}
 | 
			
		||||
	client_peer = proc_add_peer(client_proc, fd, client_dispatch,
 | 
			
		||||
	    (void *)shellcmd);
 | 
			
		||||
	client_peer = proc_add_peer(client_proc, fd, client_dispatch, NULL);
 | 
			
		||||
 | 
			
		||||
	/* Save these before pledge(). */
 | 
			
		||||
	if ((cwd = getcwd(path, sizeof path)) == NULL) {
 | 
			
		||||
@@ -533,7 +531,7 @@ client_signal(int sig)
 | 
			
		||||
 | 
			
		||||
/* Callback for client read events. */
 | 
			
		||||
static void
 | 
			
		||||
client_dispatch(struct imsg *imsg, void *arg)
 | 
			
		||||
client_dispatch(struct imsg *imsg, __unused void *arg)
 | 
			
		||||
{
 | 
			
		||||
	if (imsg == NULL) {
 | 
			
		||||
		client_exitreason = CLIENT_EXIT_LOST_SERVER;
 | 
			
		||||
@@ -545,12 +543,12 @@ client_dispatch(struct imsg *imsg, void *arg)
 | 
			
		||||
	if (client_attached)
 | 
			
		||||
		client_dispatch_attached(imsg);
 | 
			
		||||
	else
 | 
			
		||||
		client_dispatch_wait(imsg, arg);
 | 
			
		||||
		client_dispatch_wait(imsg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Dispatch imsgs when in wait state (before MSG_READY). */
 | 
			
		||||
static void
 | 
			
		||||
client_dispatch_wait(struct imsg *imsg, const char *shellcmd)
 | 
			
		||||
client_dispatch_wait(struct imsg *imsg)
 | 
			
		||||
{
 | 
			
		||||
	char			*data;
 | 
			
		||||
	ssize_t			 datalen;
 | 
			
		||||
@@ -630,7 +628,7 @@ client_dispatch_wait(struct imsg *imsg, const char *shellcmd)
 | 
			
		||||
			fatalx("bad MSG_SHELL string");
 | 
			
		||||
 | 
			
		||||
		clear_signals(0);
 | 
			
		||||
		client_exec(data, shellcmd);
 | 
			
		||||
		client_exec(data, shell_command);
 | 
			
		||||
		/* NOTREACHED */
 | 
			
		||||
	case MSG_DETACH:
 | 
			
		||||
	case MSG_DETACHKILL:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								tmux.c
									
									
									
									
									
								
							@@ -44,6 +44,7 @@ struct hooks	*global_hooks;
 | 
			
		||||
struct timeval	 start_time;
 | 
			
		||||
const char	*socket_path;
 | 
			
		||||
int		 ptm_fd = -1;
 | 
			
		||||
const char	*shell_command;
 | 
			
		||||
 | 
			
		||||
static __dead void	 usage(void);
 | 
			
		||||
static char		*make_label(const char *);
 | 
			
		||||
@@ -190,8 +191,8 @@ find_home(void)
 | 
			
		||||
int
 | 
			
		||||
main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	char					*path, *label, tmp[PATH_MAX];
 | 
			
		||||
	char					*shellcmd = NULL, **var;
 | 
			
		||||
	char					*path, *label, **var;
 | 
			
		||||
	char					 tmp[PATH_MAX];
 | 
			
		||||
	const char				*s, *shell;
 | 
			
		||||
	int					 opt, flags, keys;
 | 
			
		||||
	const struct options_table_entry	*oe;
 | 
			
		||||
@@ -220,8 +221,7 @@ main(int argc, char **argv)
 | 
			
		||||
			flags |= CLIENT_256COLOURS;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'c':
 | 
			
		||||
			free(shellcmd);
 | 
			
		||||
			shellcmd = xstrdup(optarg);
 | 
			
		||||
			shell_command = optarg;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'C':
 | 
			
		||||
			if (flags & CLIENT_CONTROL)
 | 
			
		||||
@@ -258,7 +258,7 @@ main(int argc, char **argv)
 | 
			
		||||
	argc -= optind;
 | 
			
		||||
	argv += optind;
 | 
			
		||||
 | 
			
		||||
	if (shellcmd != NULL && argc != 0)
 | 
			
		||||
	if (shell_command != NULL && argc != 0)
 | 
			
		||||
		usage();
 | 
			
		||||
 | 
			
		||||
	if ((ptm_fd = getptmfd()) == -1)
 | 
			
		||||
@@ -348,5 +348,5 @@ main(int argc, char **argv)
 | 
			
		||||
	free(label);
 | 
			
		||||
 | 
			
		||||
	/* Pass control to the client. */
 | 
			
		||||
	exit(client_main(event_init(), argc, argv, flags, shellcmd));
 | 
			
		||||
	exit(client_main(event_init(), argc, argv, flags));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1486,6 +1486,7 @@ extern struct environ	*global_environ;
 | 
			
		||||
extern struct timeval	 start_time;
 | 
			
		||||
extern const char	*socket_path;
 | 
			
		||||
extern int		 ptm_fd;
 | 
			
		||||
extern const char	*shell_command;
 | 
			
		||||
int		 areshell(const char *);
 | 
			
		||||
void		 setblocking(int, int);
 | 
			
		||||
const char	*find_home(void);
 | 
			
		||||
@@ -1820,7 +1821,7 @@ struct cmd_list	*cmd_string_parse(const char *, const char *, u_int, char **);
 | 
			
		||||
void	cmd_wait_for_flush(void);
 | 
			
		||||
 | 
			
		||||
/* client.c */
 | 
			
		||||
int	client_main(struct event_base *, int, char **, int, const char *);
 | 
			
		||||
int	client_main(struct event_base *, int, char **, int);
 | 
			
		||||
 | 
			
		||||
/* key-bindings.c */
 | 
			
		||||
RB_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user