Merge branch 'obsd-master'

pull/1805/head
Thomas Adam 2019-06-20 09:02:26 +01:00
commit 03945276f7
7 changed files with 88 additions and 52 deletions

View File

@ -212,7 +212,9 @@ args_escape(const char *s)
if (*s == '\0') if (*s == '\0')
return (xstrdup(s)); return (xstrdup(s));
if ((strchr(quoted, s[0]) != NULL || s[0] == '~') && s[1] == '\0') { if (s[0] != ' ' &&
(strchr(quoted, s[0]) != NULL || s[0] == '~') &&
s[1] == '\0') {
xasprintf(&escaped, "\\%c", s[0]); xasprintf(&escaped, "\\%c", s[0]);
return (escaped); return (escaped);
} }

7
cfg.c
View File

@ -90,14 +90,14 @@ start_cfg(void)
} }
if (cfg_file == NULL) if (cfg_file == NULL)
load_cfg(TMUX_CONF, NULL, NULL, CMD_PARSE_QUIET, NULL); load_cfg(TMUX_CONF, c, NULL, CMD_PARSE_QUIET, NULL);
if (cfg_file == NULL && (home = find_home()) != NULL) { if (cfg_file == NULL && (home = find_home()) != NULL) {
xasprintf(&cfg_file, "%s/.tmux.conf", home); xasprintf(&cfg_file, "%s/.tmux.conf", home);
flags = CMD_PARSE_QUIET; flags = CMD_PARSE_QUIET;
} }
if (cfg_file != NULL) if (cfg_file != NULL)
load_cfg(cfg_file, NULL, NULL, flags, NULL); load_cfg(cfg_file, c, NULL, flags, NULL);
cmdq_append(NULL, cmdq_get_callback(cfg_done, NULL)); cmdq_append(NULL, cmdq_get_callback(cfg_done, NULL));
} }
@ -127,6 +127,7 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
pi.file = path; pi.file = path;
pi.line = 1; pi.line = 1;
pi.item = item; pi.item = item;
pi.c = c;
pr = cmd_parse_from_file(f, &pi); pr = cmd_parse_from_file(f, &pi);
fclose(f); fclose(f);
@ -146,7 +147,7 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
if (item != NULL) if (item != NULL)
cmdq_insert_after(item, new_item0); cmdq_insert_after(item, new_item0);
else else
cmdq_append(c, new_item0); cmdq_append(NULL, new_item0);
cmd_list_free(pr->cmdlist); cmd_list_free(pr->cmdlist);
if (new_item != NULL) if (new_item != NULL)

View File

@ -30,16 +30,16 @@
static enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmdq_item *); static enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmdq_item *);
static void cmd_show_options_print(struct cmd *, struct cmdq_item *, static void cmd_show_options_print(struct cmd *, struct cmdq_item *,
struct options_entry *, int); struct options_entry *, int, int);
static enum cmd_retval cmd_show_options_all(struct cmd *, struct cmdq_item *, static enum cmd_retval cmd_show_options_all(struct cmd *, struct cmdq_item *,
struct options *); enum options_table_scope, struct options *);
const struct cmd_entry cmd_show_options_entry = { const struct cmd_entry cmd_show_options_entry = {
.name = "show-options", .name = "show-options",
.alias = "show", .alias = "show",
.args = { "gHqst:vw", 0, 1 }, .args = { "AgHqst:vw", 0, 1 },
.usage = "[-gHqsvw] [-t target-session|target-window] [option]", .usage = "[-AgHqsvw] [-t target-session|target-window] [option]",
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL }, .target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
@ -85,7 +85,7 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
enum options_table_scope scope; enum options_table_scope scope;
char *argument, *name = NULL, *cause; char *argument, *name = NULL, *cause;
const char *target; const char *target;
int window, idx, ambiguous; int window, idx, ambiguous, parent;
struct options_entry *o; struct options_entry *o;
window = (self->entry == &cmd_show_window_options_entry); window = (self->entry == &cmd_show_window_options_entry);
@ -98,7 +98,7 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
free(cause); free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
return (cmd_show_options_all(self, item, oo)); return (cmd_show_options_all(self, item, scope, oo));
} }
argument = format_single(item, args->argv[0], c, s, wl, NULL); argument = format_single(item, args->argv[0], c, s, wl, NULL);
@ -163,8 +163,13 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
goto fail; goto fail;
} }
o = options_get_only(oo, name); o = options_get_only(oo, name);
if (args_has(args, 'A') && o == NULL) {
o = options_get(oo, name);
parent = 1;
} else
parent = 0;
if (o != NULL) if (o != NULL)
cmd_show_options_print(self, item, o, idx); cmd_show_options_print(self, item, o, idx, parent);
free(name); free(name);
free(argument); free(argument);
@ -178,7 +183,7 @@ fail:
static void static void
cmd_show_options_print(struct cmd *self, struct cmdq_item *item, cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
struct options_entry *o, int idx) struct options_entry *o, int idx, int parent)
{ {
struct options_array_item *a; struct options_array_item *a;
const char *name = options_name(o); const char *name = options_name(o);
@ -197,7 +202,8 @@ cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
} }
while (a != NULL) { while (a != NULL) {
idx = options_array_item_index(a); idx = options_array_item_index(a);
cmd_show_options_print(self, item, o, idx); cmd_show_options_print(self, item, o, idx,
parent);
a = options_array_next(a); a = options_array_next(a);
} }
return; return;
@ -209,10 +215,17 @@ cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
cmdq_print(item, "%s", value); cmdq_print(item, "%s", value);
else if (options_isstring(o)) { else if (options_isstring(o)) {
escaped = args_escape(value); escaped = args_escape(value);
cmdq_print(item, "%s %s", name, escaped); if (parent)
cmdq_print(item, "%s* %s", name, escaped);
else
cmdq_print(item, "%s %s", name, escaped);
free(escaped); free(escaped);
} else } else {
cmdq_print(item, "%s %s", name, value); if (parent)
cmdq_print(item, "%s* %s", name, value);
else
cmdq_print(item, "%s %s", name, value);
}
free(value); free(value);
free(tmp); free(tmp);
@ -220,39 +233,54 @@ cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
static enum cmd_retval static enum cmd_retval
cmd_show_options_all(struct cmd *self, struct cmdq_item *item, cmd_show_options_all(struct cmd *self, struct cmdq_item *item,
struct options *oo) enum options_table_scope scope, struct options *oo)
{ {
const struct options_table_entry *oe;
struct options_entry *o; struct options_entry *o;
struct options_array_item *a; struct options_array_item *a;
u_int idx; u_int idx;
const struct options_table_entry *oe; int parent;
for (oe = options_table; oe->name != NULL; oe++) {
if (oe->scope != scope)
continue;
o = options_first(oo);
while (o != NULL) {
oe = options_table_entry(o);
if ((self->entry != &cmd_show_hooks_entry && if ((self->entry != &cmd_show_hooks_entry &&
!args_has(self->args, 'H') && !args_has(self->args, 'H') &&
oe != NULL && oe != NULL &&
(oe->flags & OPTIONS_TABLE_IS_HOOK)) || (oe->flags & OPTIONS_TABLE_IS_HOOK)) ||
(self->entry == &cmd_show_hooks_entry && (self->entry == &cmd_show_hooks_entry &&
(oe == NULL || (oe == NULL ||
(~oe->flags & OPTIONS_TABLE_IS_HOOK)))) { (~oe->flags & OPTIONS_TABLE_IS_HOOK))))
o = options_next(o);
continue; continue;
}
o = options_get_only(oo, oe->name);
if (o == NULL) {
if (!args_has(self->args, 'A'))
continue;
o = options_get(oo, oe->name);
if (o == NULL)
continue;
parent = 1;
} else
parent = 0;
if (!options_isarray(o)) if (!options_isarray(o))
cmd_show_options_print(self, item, o, -1); cmd_show_options_print(self, item, o, -1, parent);
else if ((a = options_array_first(o)) == NULL) { else if ((a = options_array_first(o)) == NULL) {
if (!args_has(self->args, 'v')) if (!args_has(self->args, 'v')) {
cmdq_print(item, "%s", options_name(o)); if (parent)
cmdq_print(item, "%s*", options_name(o));
else
cmdq_print(item, "%s", options_name(o));
}
} else { } else {
while (a != NULL) { while (a != NULL) {
idx = options_array_item_index(a); idx = options_array_item_index(a);
cmd_show_options_print(self, item, o, idx); cmd_show_options_print(self, item, o, idx, parent);
a = options_array_next(a); a = options_array_next(a);
} }
} }
o = options_next(o);
} }
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@ -2022,10 +2022,10 @@ void
format_defaults(struct format_tree *ft, struct client *c, struct session *s, format_defaults(struct format_tree *ft, struct client *c, struct session *s,
struct winlink *wl, struct window_pane *wp) struct winlink *wl, struct window_pane *wp)
{ {
if (c != NULL) if (c != NULL && c->name != NULL)
log_debug("%s: c=%s", __func__, c->name); log_debug("%s: c=%s", __func__, c->name);
else else
log_debug("%s: s=none", __func__); log_debug("%s: c=none", __func__);
if (s != NULL) if (s != NULL)
log_debug("%s: s=$%u", __func__, s->id); log_debug("%s: s=$%u", __func__, s->id);
else else

View File

@ -1948,26 +1948,29 @@ server_client_dispatch_identify(struct client *c, struct imsg *imsg)
close(c->fd); close(c->fd);
c->fd = -1; c->fd = -1;
} else if (c->fd != -1) {
return; if (tty_init(&c->tty, c, c->fd, c->term) != 0) {
close(c->fd);
c->fd = -1;
} else {
if (c->flags & CLIENT_UTF8)
c->tty.flags |= TTY_UTF8;
if (c->flags & CLIENT_256COLOURS)
c->tty.term_flags |= TERM_256COLOURS;
tty_resize(&c->tty);
c->flags |= CLIENT_TERMINAL;
}
} }
if (c->fd == -1) /*
return; * If this is the first client that has finished identifying, load
if (tty_init(&c->tty, c, c->fd, c->term) != 0) { * configuration files.
close(c->fd); */
c->fd = -1; if ((~c->flags & CLIENT_EXIT) &&
return; !cfg_finished &&
} c == TAILQ_FIRST(&clients) &&
if (c->flags & CLIENT_UTF8) TAILQ_NEXT(c, entry) == NULL)
c->tty.flags |= TTY_UTF8; start_cfg();
if (c->flags & CLIENT_256COLOURS)
c->tty.term_flags |= TERM_256COLOURS;
tty_resize(&c->tty);
if (!(c->flags & CLIENT_CONTROL))
c->flags |= CLIENT_TERMINAL;
} }
/* Handle shell message. */ /* Handle shell message. */

View File

@ -207,8 +207,7 @@ server_start(struct tmuxproc *client, struct event_base *base, int lockfd,
cmdq_append(c, cmdq_get_error(cause)); cmdq_append(c, cmdq_get_error(cause));
free(cause); free(cause);
c->flags |= CLIENT_EXIT; c->flags |= CLIENT_EXIT;
} else }
start_cfg();
server_add_accept(0); server_add_accept(0);
proc_loop(server_proc, server_loop); proc_loop(server_proc, server_loop);

5
tmux.1
View File

@ -3685,7 +3685,7 @@ function key sequences; these have a number included to indicate modifiers such
as Shift, Alt or Ctrl. as Shift, Alt or Ctrl.
.El .El
.It Xo Ic show-options .It Xo Ic show-options
.Op Fl gHqsvw .Op Fl AgHqsvw
.Op Fl t Ar target-session | Ar target-window .Op Fl t Ar target-session | Ar target-window
.Op Ar option .Op Ar option
.Xc .Xc
@ -3719,6 +3719,9 @@ is set, no error will be returned if
is unset. is unset.
.Fl H .Fl H
includes hooks (omitted by default). includes hooks (omitted by default).
.Fl A
includes options inherited from a parent set of options, such options are
marked with an asterisk.
.It Xo Ic show-window-options .It Xo Ic show-window-options
.Op Fl gv .Op Fl gv
.Op Fl t Ar target-window .Op Fl t Ar target-window