summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-06-20 07:10:57 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-06-20 07:10:57 +0000
commitf85924615ecfd4fa83626c2f05162651da61781b (patch)
treec83c1ae4569637f310bd2d9dbd4fbc0c302cb5c1 /usr.bin
parent799dd7d5ba631a0c88b83bd812ef2aa3f7f5a1ab (diff)
Add a -A flag to show-options to show parent options as well.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/arguments.c6
-rw-r--r--usr.bin/tmux/cmd-show-options.c80
-rw-r--r--usr.bin/tmux/tmux.19
3 files changed, 64 insertions, 31 deletions
diff --git a/usr.bin/tmux/arguments.c b/usr.bin/tmux/arguments.c
index 41562fd4dcc..08a72817412 100644
--- a/usr.bin/tmux/arguments.c
+++ b/usr.bin/tmux/arguments.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arguments.c,v 1.25 2019/05/29 20:05:14 nicm Exp $ */
+/* $OpenBSD: arguments.c,v 1.26 2019/06/20 07:10:56 nicm Exp $ */
/*
* Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -213,7 +213,9 @@ args_escape(const char *s)
if (*s == '\0')
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]);
return (escaped);
}
diff --git a/usr.bin/tmux/cmd-show-options.c b/usr.bin/tmux/cmd-show-options.c
index c3812756dd9..9ba8e19795b 100644
--- a/usr.bin/tmux/cmd-show-options.c
+++ b/usr.bin/tmux/cmd-show-options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-show-options.c,v 1.53 2019/05/23 18:33:53 nicm Exp $ */
+/* $OpenBSD: cmd-show-options.c,v 1.54 2019/06/20 07:10:56 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -31,16 +31,16 @@
static enum cmd_retval cmd_show_options_exec(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 *,
- struct options *);
+ enum options_table_scope, struct options *);
const struct cmd_entry cmd_show_options_entry = {
.name = "show-options",
.alias = "show",
- .args = { "gHqst:vw", 0, 1 },
- .usage = "[-gHqsvw] [-t target-session|target-window] [option]",
+ .args = { "AgHqst:vw", 0, 1 },
+ .usage = "[-AgHqsvw] [-t target-session|target-window] [option]",
.target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
@@ -86,7 +86,7 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
enum options_table_scope scope;
char *argument, *name = NULL, *cause;
const char *target;
- int window, idx, ambiguous;
+ int window, idx, ambiguous, parent;
struct options_entry *o;
window = (self->entry == &cmd_show_window_options_entry);
@@ -99,7 +99,7 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
free(cause);
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);
@@ -164,8 +164,13 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
goto fail;
}
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)
- cmd_show_options_print(self, item, o, idx);
+ cmd_show_options_print(self, item, o, idx, parent);
free(name);
free(argument);
@@ -179,7 +184,7 @@ fail:
static void
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;
const char *name = options_name(o);
@@ -198,7 +203,8 @@ cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
}
while (a != NULL) {
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);
}
return;
@@ -210,10 +216,17 @@ cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
cmdq_print(item, "%s", value);
else if (options_isstring(o)) {
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);
- } else
- cmdq_print(item, "%s %s", name, value);
+ } else {
+ if (parent)
+ cmdq_print(item, "%s* %s", name, value);
+ else
+ cmdq_print(item, "%s %s", name, value);
+ }
free(value);
free(tmp);
@@ -221,39 +234,54 @@ cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
static enum cmd_retval
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_array_item *a;
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 &&
!args_has(self->args, 'H') &&
oe != NULL &&
(oe->flags & OPTIONS_TABLE_IS_HOOK)) ||
(self->entry == &cmd_show_hooks_entry &&
(oe == NULL ||
- (~oe->flags & OPTIONS_TABLE_IS_HOOK)))) {
- o = options_next(o);
+ (~oe->flags & OPTIONS_TABLE_IS_HOOK))))
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))
- 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) {
- if (!args_has(self->args, 'v'))
- cmdq_print(item, "%s", options_name(o));
+ if (!args_has(self->args, 'v')) {
+ if (parent)
+ cmdq_print(item, "%s*", options_name(o));
+ else
+ cmdq_print(item, "%s", options_name(o));
+ }
} else {
while (a != NULL) {
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);
}
}
- o = options_next(o);
}
return (CMD_RETURN_NORMAL);
}
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 4b13d346989..3afe4e5ae8f 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.666 2019/06/14 12:04:11 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.667 2019/06/20 07:10:56 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 14 2019 $
+.Dd $Mdocdate: June 20 2019 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -3680,7 +3680,7 @@ function key sequences; these have a number included to indicate modifiers such
as Shift, Alt or Ctrl.
.El
.It Xo Ic show-options
-.Op Fl gHqsvw
+.Op Fl AgHqsvw
.Op Fl t Ar target-session | Ar target-window
.Op Ar option
.Xc
@@ -3714,6 +3714,9 @@ is set, no error will be returned if
is unset.
.Fl H
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
.Op Fl gv
.Op Fl t Ar target-window