diff options
author | 2016-10-09 07:58:35 +0000 | |
---|---|---|
committer | 2016-10-09 07:58:35 +0000 | |
commit | cd165faf66656c1acb811d866adf081cdf1e9ddf (patch) | |
tree | 6bd6ca263f14ab2a06a682b4975f1e7a4270f6e8 /usr.bin/tmux/cmd-set-option.c | |
parent | Use xsnprintf not snprintf for the prompt in window_copy_write_line (diff) | |
download | wireguard-openbsd-cd165faf66656c1acb811d866adf081cdf1e9ddf.tar.xz wireguard-openbsd-cd165faf66656c1acb811d866adf081cdf1e9ddf.zip |
Handle NULL window or session for user options.
Diffstat (limited to 'usr.bin/tmux/cmd-set-option.c')
-rw-r--r-- | usr.bin/tmux/cmd-set-option.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index faa1bc30851..d3a7de00709 100644 --- a/usr.bin/tmux/cmd-set-option.c +++ b/usr.bin/tmux/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.97 2016/09/26 09:02:34 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.98 2016/10/09 07:58:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -232,6 +232,7 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr, struct winlink *wl = cmdq->state.tflag.wl; struct options *oo; struct options_entry *o; + const char *target; if (args_has(args, 's')) oo = global_options; @@ -239,12 +240,28 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr, self->entry == &cmd_set_window_option_entry) { 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 { 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; } |