diff options
author | nicm <nicm> | 2016-03-03 14:15:22 +0000 |
---|---|---|
committer | nicm <nicm> | 2016-03-03 14:15:22 +0000 |
commit | df0983af39922f2ee747a244c1c718ba7ca28910 (patch) | |
tree | 419ef6877cc12ee4942198fc7b4f2c5755feaba0 /cmd-show-options.c | |
parent | fa81d838dacb2dd05d4556db3cbcb3760b7d2c47 (diff) | |
download | rtmux-df0983af39922f2ee747a244c1c718ba7ca28910.tar.gz rtmux-df0983af39922f2ee747a244c1c718ba7ca28910.tar.bz2 rtmux-df0983af39922f2ee747a244c1c718ba7ca28910.zip |
show-* and set-* need to handle a missing target.
Diffstat (limited to 'cmd-show-options.c')
-rw-r--r-- | cmd-show-options.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/cmd-show-options.c b/cmd-show-options.c index fec2f1de..322f532c 100644 --- a/cmd-show-options.c +++ b/cmd-show-options.c @@ -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; } |