aboutsummaryrefslogtreecommitdiff
path: root/cmd-set-option.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2013-02-23 23:21:22 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2013-02-23 23:22:03 +0000
commitbe13479f099749b2a199e17505797e51090caca0 (patch)
treea8a967722c6463b83ed0e84f312afa4a339a7413 /cmd-set-option.c
parent69a8d6471634ebdfa9db70b306e493f47ddd9a5d (diff)
downloadrtmux-be13479f099749b2a199e17505797e51090caca0.tar.gz
rtmux-be13479f099749b2a199e17505797e51090caca0.tar.bz2
rtmux-be13479f099749b2a199e17505797e51090caca0.zip
Add a -o option to set-option to prevent setting an option already set, from
Thiago Padilha.
Diffstat (limited to 'cmd-set-option.c')
-rw-r--r--cmd-set-option.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c
index 4b351c19..a46460a8 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -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,