summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-show-options.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2016-03-03 14:15:23 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2016-03-03 14:15:23 +0000
commit1e24b1a85d274af46535cec96788be2e00cb8649 (patch)
treee9c6db7e2a9f22736158445397761adc8f837349 /usr.bin/tmux/cmd-show-options.c
parent818d7160c4141e9369173352b52d8babfd7d95a1 (diff)
show-* and set-* need to handle a missing target.
Diffstat (limited to 'usr.bin/tmux/cmd-show-options.c')
-rw-r--r--usr.bin/tmux/cmd-show-options.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/usr.bin/tmux/cmd-show-options.c b/usr.bin/tmux/cmd-show-options.c
index 2e654139821..9e0f518f330 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.30 2016/01/19 15:59:12 nicm Exp $ */
+/* $OpenBSD: cmd-show-options.c,v 1.31 2016/03/03 14:15:22 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -63,12 +63,13 @@ const struct cmd_entry cmd_show_window_options_entry = {
enum cmd_retval
cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
{
- struct args *args = self->args;
- struct session *s = cmdq->state.tflag.s;
- struct winlink *wl = cmdq->state.tflag.wl;
- struct options *oo;
- enum options_table_scope scope;
- int quiet;
+ struct args *args = self->args;
+ struct session *s = cmdq->state.tflag.s;
+ struct winlink *wl = cmdq->state.tflag.wl;
+ struct options *oo;
+ enum options_table_scope scope;
+ int quiet;
+ const char *target;
if (args_has(self->args, 's')) {
oo = global_options;
@@ -78,13 +79,27 @@ cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
scope = OPTIONS_TABLE_WINDOW;
if (args_has(self->args, 'g'))
oo = global_w_options;
- else
+ else if (wl == NULL) {
+ target = args_get(args, 't');
+ if (target != NULL) {
+ cmdq_error(cmdq, "no such window: %s", target);
+ } else
+ cmdq_error(cmdq, "no current window");
+ return (CMD_RETURN_ERROR);
+ } else
oo = wl->window->options;
} else {
scope = OPTIONS_TABLE_SESSION;
if (args_has(self->args, 'g'))
oo = global_s_options;
- else
+ else if (s == NULL) {
+ target = args_get(args, 't');
+ if (target != NULL) {
+ cmdq_error(cmdq, "no such session: %s", target);
+ } else
+ cmdq_error(cmdq, "no current session");
+ return (CMD_RETURN_ERROR);
+ } else
oo = s->options;
}