aboutsummaryrefslogtreecommitdiff
path: root/cmd-set-option.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2017-01-24 20:01:12 +0000
committerThomas Adam <thomas@xteddy.org>2017-01-24 20:01:12 +0000
commitf38a6bbd816533d01d14c8bbafbb51621e5e1326 (patch)
treea76cb484291fe739a9bf76e937dd5cc5cb1da124 /cmd-set-option.c
parentf1282a683de191d00e6f71cc4a7d4c9646fff3de (diff)
parent61fce272ea60f5096711ee554c56aef9cca8c654 (diff)
downloadrtmux-f38a6bbd816533d01d14c8bbafbb51621e5e1326.tar.gz
rtmux-f38a6bbd816533d01d14c8bbafbb51621e5e1326.tar.bz2
rtmux-f38a6bbd816533d01d14c8bbafbb51621e5e1326.zip
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-set-option.c')
-rw-r--r--cmd-set-option.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c
index ef2ce10b..84c12e56 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -160,11 +160,17 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "not an array: %s", args->argv[0]);
return (CMD_RETURN_ERROR);
}
- } else {
- if (*name != '@' && options_array_size(parent, NULL) != -1) {
- cmdq_error(item, "is an array: %s", args->argv[0]);
- return (CMD_RETURN_ERROR);
+ } else if (*name != '@' && options_array_size(parent, NULL) != -1) {
+ if (value == NULL) {
+ cmdq_error(item, "empty value");
+ return (-1);
}
+ if (o == NULL)
+ o = options_empty(oo, options_table_entry(parent));
+ if (!args_has(args, 'a'))
+ options_array_clear(o);
+ options_array_assign(o, value);
+ return (CMD_RETURN_NORMAL);
}
/* With -o, check this option is not already set. */
@@ -197,7 +203,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
else
options_remove(o);
} else
- options_array_set(o, idx, NULL);
+ options_array_set(o, idx, NULL, 0);
} else if (*name == '@')
options_set_string(oo, name, args_has(args, 'a'), "%s", value);
else if (idx == -1) {
@@ -207,7 +213,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
} else {
if (o == NULL)
o = options_empty(oo, options_table_entry(parent));
- if (options_array_set(o, idx, value) != 0) {
+ if (options_array_set(o, idx, value, 1) != 0) {
cmdq_error(item, "invalid index: %s", args->argv[0]);
return (CMD_RETURN_ERROR);
}