mirror of
https://github.com/tmux/tmux.git
synced 2025-04-28 16:40:36 +00:00
Fix set -u on array options.
This commit is contained in:
parent
4b2821ff98
commit
ffc28a7765
@ -68,6 +68,7 @@ static enum cmd_retval
|
|||||||
cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
|
int append = args_has(args, 'a');
|
||||||
struct cmd_find_state *fs = &item->state.tflag;
|
struct cmd_find_state *fs = &item->state.tflag;
|
||||||
struct session *s = fs->s;
|
struct session *s = fs->s;
|
||||||
struct winlink *wl = fs->wl;
|
struct winlink *wl = fs->wl;
|
||||||
@ -160,17 +161,6 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
cmdq_error(item, "not an array: %s", args->argv[0]);
|
cmdq_error(item, "not an array: %s", args->argv[0]);
|
||||||
return (CMD_RETURN_ERROR);
|
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. */
|
/* With -o, check this option is not already set. */
|
||||||
@ -204,16 +194,26 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
options_remove(o);
|
options_remove(o);
|
||||||
} else
|
} else
|
||||||
options_array_set(o, idx, NULL, 0);
|
options_array_set(o, idx, NULL, 0);
|
||||||
} else if (*name == '@')
|
} else if (*name == '@') {
|
||||||
options_set_string(oo, name, args_has(args, 'a'), "%s", value);
|
if (value == NULL) {
|
||||||
else if (idx == -1) {
|
cmdq_error(item, "empty value");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
|
options_set_string(oo, name, append, "%s", value);
|
||||||
|
} else if (idx == -1 && options_array_size(parent, NULL) == -1) {
|
||||||
error = cmd_set_option_set(self, item, oo, parent, value);
|
error = cmd_set_option_set(self, item, oo, parent, value);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
} else {
|
} else {
|
||||||
|
if (value == NULL) {
|
||||||
|
cmdq_error(item, "empty value");
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
|
}
|
||||||
if (o == NULL)
|
if (o == NULL)
|
||||||
o = options_empty(oo, options_table_entry(parent));
|
o = options_empty(oo, options_table_entry(parent));
|
||||||
if (options_array_set(o, idx, value, 1) != 0) {
|
if (idx == -1)
|
||||||
|
options_array_assign(o, value);
|
||||||
|
else if (options_array_set(o, idx, value, append) != 0) {
|
||||||
cmdq_error(item, "invalid index: %s", args->argv[0]);
|
cmdq_error(item, "invalid index: %s", args->argv[0]);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user