Merge branch 'obsd-master'

pull/2075/head
Thomas Adam 2020-01-28 11:17:08 +00:00
commit ee3d3db364
5 changed files with 40 additions and 20 deletions

View File

@ -1121,7 +1121,7 @@ format_create(struct client *c, struct cmdq_item *item, int tag, int flags)
ft->flags = flags;
ft->time = time(NULL);
format_add(ft, "version", "%s", VERSION);
format_add(ft, "version", "%s", getversion());
format_add_cb(ft, "host", format_cb_host);
format_add_cb(ft, "host_short", format_cb_host_short);
format_add_cb(ft, "pid", format_cb_pid);

2
proc.c
View File

@ -181,7 +181,7 @@ proc_start(const char *name)
memset(&u, 0, sizeof u);
log_debug("%s started (%ld): version %s, socket %s, protocol %d", name,
(long)getpid(), VERSION, socket_path, PROTOCOL_VERSION);
(long)getpid(), getversion(), socket_path, PROTOCOL_VERSION);
log_debug("on %s %s %s; libevent %s (%s)", u.sysname, u.release,
u.version, event_get_version(), event_get_method());

35
spawn.c
View File

@ -223,6 +223,17 @@ spawn_pane(struct spawn_context *sc, char **cause)
spawn_log(__func__, sc);
/*
* Work out the current working directory. If respawning, use
* the pane's stored one unless specified.
*/
if (sc->cwd != NULL)
cwd = format_single(item, sc->cwd, c, s, NULL, NULL);
else if (~sc->flags & SPAWN_RESPAWN)
cwd = xstrdup(server_client_get_cwd(c, s));
else
cwd = NULL;
/*
* If we are respawning then get rid of the old process. Otherwise
* either create a new cell or assign to the one we are given.
@ -233,6 +244,7 @@ spawn_pane(struct spawn_context *sc, char **cause)
window_pane_index(sc->wp0, &idx);
xasprintf(cause, "pane %s:%d.%u still active",
s->name, sc->wl->idx, idx);
free(cwd);
return (NULL);
}
if (sc->wp0->fd != -1) {
@ -253,8 +265,8 @@ spawn_pane(struct spawn_context *sc, char **cause)
}
/*
* Now we have a pane with nothing running in it ready for the new
* process. Work out the command and arguments.
* Now we have a pane with nothing running in it ready for the new process.
* Work out the command and arguments and store the working directory.
*/
if (sc->argc == 0 && (~sc->flags & SPAWN_RESPAWN)) {
cmd = options_get_string(s->options, "default-command");
@ -269,6 +281,10 @@ spawn_pane(struct spawn_context *sc, char **cause)
argc = sc->argc;
argv = sc->argv;
}
if (cwd != NULL) {
free(new_wp->cwd);
new_wp->cwd = cwd;
}
/*
* Replace the stored arguments if there are new ones. If not, the
@ -280,21 +296,6 @@ spawn_pane(struct spawn_context *sc, char **cause)
new_wp->argv = cmd_copy_argv(argc, argv);
}
/*
* Work out the current working directory. If respawning, use
* the pane's stored one unless specified.
*/
if (sc->cwd != NULL)
cwd = format_single(item, sc->cwd, c, s, NULL, NULL);
else if (~sc->flags & SPAWN_RESPAWN)
cwd = xstrdup(server_client_get_cwd(c, s));
else
cwd = NULL;
if (cwd != NULL) {
free(new_wp->cwd);
new_wp->cwd = cwd;
}
/* Create an environment for this pane. */
child = environ_for_session(s, 0);
if (sc->environ != NULL)

20
tmux.c
View File

@ -18,6 +18,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <errno.h>
#include <event.h>
@ -209,6 +210,20 @@ find_home(void)
return (home);
}
const char *
getversion(void)
{
static char *version;
struct utsname u;
if (version == NULL) {
if (uname(&u) < 0)
fatalx("uname failed");
xasprintf(&version, "openbsd-%s", u.release);
}
return version;
}
int
main(int argc, char **argv)
{
@ -235,7 +250,7 @@ main(int argc, char **argv)
flags = 0;
label = path = NULL;
while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:uUVv")) != -1) {
while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:uUvV")) != -1) {
switch (opt) {
case '2':
flags |= CLIENT_256COLOURS;
@ -255,6 +270,9 @@ main(int argc, char **argv)
case 'f':
set_cfg_file(optarg);
break;
case 'V':
printf("%s %s\n", getprogname(), getversion());
exit(0);
case 'l':
flags |= CLIENT_LOGIN;
break;

1
tmux.h
View File

@ -1771,6 +1771,7 @@ int areshell(const char *);
void setblocking(int, int);
const char *find_cwd(void);
const char *find_home(void);
const char *getversion(void);
/* proc.c */
struct imsg;