When the 'set' command is used without any switches, the lookup happens
within whichever table is found for the option being set.  Usually this
isn't a problem, since missing -t flags assume a valid context.  However,
when a 'set' command is read from a config file, especially at startup, then
the context is not known and an error is thrown.   But there is never any
message set to explain why the 'set' command didn't work.

This comes up a lot on IRC when people really meant to use '-g' but haven't,
but equally we didn't set an error message either.
---
 cmd-set-option.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/cmd-set-option.c b/cmd-set-option.c
index a46460a..49bf52f 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -128,8 +128,14 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
                        oo = &global_w_options;
                else {
                        wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
-                       if (wl == NULL)
+                       if (wl == NULL) {
+                               cmdq_error(cmdq,
+                                   "couldn't set '%s' %s", optstr,
+                                   (!args_has(args, 't') && !args_has(args,
+                                   'g')) ? "no window or global option used" :
+                                   "");
                                return (CMD_RETURN_ERROR);
+                       }
                        oo = &wl->window->options;
                }
        } else if (table == session_options_table) {
@@ -137,8 +143,14 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
                        oo = &global_s_options;
                else {
                        s = cmd_find_session(cmdq, args_get(args, 't'), 0);
-                       if (s == NULL)
+                       if (s == NULL) {
+                               cmdq_error(cmdq,
+                                   "couldn't set '%s' %s", optstr,
+                                   (!args_has(args, 't') && !args_has(args,
+                                   'g')) ? "no session or global option used" :
+                                   "");
                                return (CMD_RETURN_ERROR);
+                       }
                        oo = &s->options;
                }
        } else {
-- 
1.8.3.2


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to