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-set-option.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-set-option.c')
-rw-r--r-- | cmd-set-option.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c index 7fc81286..b1771436 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -100,7 +100,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq) struct client *c; const struct options_table_entry *oe; struct options *oo; - const char *optstr, *valstr; + const char *optstr, *valstr, *target; /* Get the option name and value. */ optstr = args->argv[0]; @@ -140,29 +140,29 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq) else if (oe->scope == OPTIONS_TABLE_WINDOW) { if (args_has(self->args, 'g')) oo = global_w_options; - else { - if (wl == NULL) { - cmdq_error(cmdq, - "couldn't set '%s'%s", optstr, - (!args_has(args, 't') && !args_has(args, - 'g')) ? " need target window or -g" : ""); - return (CMD_RETURN_ERROR); - } + 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 if (oe->scope == OPTIONS_TABLE_SESSION) { if (args_has(self->args, 'g')) oo = global_s_options; - else { - if (s == NULL) { - cmdq_error(cmdq, - "couldn't set '%s'%s", optstr, - (!args_has(args, 't') && !args_has(args, - 'g')) ? " need target session or -g" : ""); - return (CMD_RETURN_ERROR); - } + 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; - } } else { cmdq_error(cmdq, "unknown table"); return (CMD_RETURN_ERROR); |