summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-set-option.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2013-03-24 09:55:02 +0000
committernicm <nicm@openbsd.org>2013-03-24 09:55:02 +0000
commit17f4074af5eb9759ed170a1c03f5a485ca6f59c7 (patch)
tree28eeafc766c7b7c6d7648cf80d7b32af0eb148fc /usr.bin/tmux/cmd-set-option.c
parentAdd a command queue to standardize and simplify commands that call other (diff)
downloadwireguard-openbsd-17f4074af5eb9759ed170a1c03f5a485ca6f59c7.tar.xz
wireguard-openbsd-17f4074af5eb9759ed170a1c03f5a485ca6f59c7.zip
Add a -o option to set-option to prevent setting an option already set,
from Thiago Padilha.
Diffstat (limited to 'usr.bin/tmux/cmd-set-option.c')
-rw-r--r--usr.bin/tmux/cmd-set-option.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c
index 5a867ae64af..bd801c1a7c5 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.60 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-set-option.c,v 1.61 2013/03/24 09:55:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -30,7 +30,7 @@
enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmd_q *);
enum cmd_retval cmd_set_option_user(struct cmd *, struct cmd_q *,
- const char *, const char *);
+ const char *, const char *);
int cmd_set_option_unset(struct cmd *, struct cmd_q *,
const struct options_table_entry *, struct options *,
@@ -63,8 +63,8 @@ struct options_entry *cmd_set_option_choice(struct cmd *, struct cmd_q *,
const struct cmd_entry cmd_set_option_entry = {
"set-option", "set",
- "agqst:uw", 1, 2,
- "[-agsquw] [-t target-session|target-window] option [value]",
+ "agoqst:uw", 1, 2,
+ "[-agosquw] [-t target-session|target-window] option [value]",
0,
NULL,
NULL,
@@ -73,8 +73,8 @@ const struct cmd_entry cmd_set_option_entry = {
const struct cmd_entry cmd_set_window_option_entry = {
"set-window-option", "setw",
- "agqt:u", 1, 2,
- "[-agqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
+ "agoqt:u", 1, 2,
+ "[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
0,
NULL,
NULL,
@@ -151,6 +151,11 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
if (cmd_set_option_unset(self, cmdq, oe, oo, valstr) != 0)
return (CMD_RETURN_ERROR);
} else {
+ if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
+ if (!args_has(args, 'q'))
+ cmdq_print(cmdq, "already set: %s", optstr);
+ return (CMD_RETURN_NORMAL);
+ }
if (cmd_set_option_set(self, cmdq, oe, oo, valstr) != 0)
return (CMD_RETURN_ERROR);
}
@@ -227,6 +232,11 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char* optstr,
cmdq_error(cmdq, "empty value");
return (CMD_RETURN_ERROR);
}
+ if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
+ if (!args_has(args, 'q'))
+ cmdq_print(cmdq, "already set: %s", optstr);
+ return (CMD_RETURN_NORMAL);
+ }
options_set_string(oo, optstr, "%s", valstr);
if (!args_has(args, 'q')) {
cmdq_info(cmdq, "set option: %s -> %s", optstr,