aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/degesch.c b/degesch.c
index 7b8494f..57b1bf7 100644
--- a/degesch.c
+++ b/degesch.c
@@ -9347,13 +9347,15 @@ static bool
handle_command_set_add
(struct config_item *item, const char *value, struct error **e)
{
- bool result = false;
struct str_vector items;
str_vector_init (&items);
- cstr_split (item->value.string.str, ",", &items);
+ if (item->type != CONFIG_ITEM_NULL)
+ cstr_split (item->value.string.str, ",", &items);
if (items.len == 1 && !*items.vector[0])
str_vector_reset (&items);
+ // FIXME: handle multiple items properly
+ bool result = false;
if (str_vector_find (&items, value) != -1)
error_set (e, "already present in the array: %s", value);
else
@@ -9370,13 +9372,15 @@ static bool
handle_command_set_remove
(struct config_item *item, const char *value, struct error **e)
{
- bool result = false;
struct str_vector items;
str_vector_init (&items);
- cstr_split (item->value.string.str, ",", &items);
+ if (item->type != CONFIG_ITEM_NULL)
+ cstr_split (item->value.string.str, ",", &items);
if (items.len == 1 && !*items.vector[0])
str_vector_reset (&items);
+ // FIXME: handle multiple items properly
+ bool result = false;
ssize_t i = str_vector_find (&items, value);
if (i == -1)
error_set (e, "not present in the array: %s", value);
@@ -9401,15 +9405,14 @@ handle_command_set_assign_item (struct app_context *ctx,
struct error *e = NULL;
if (!item->schema)
error_set (&e, "option not recognized");
- else if ((add | remove) && item->type != CONFIG_ITEM_STRING_ARRAY)
- // FIXME: it can also be null, which makes this message confusing
+ else if (!add && !remove)
+ config_item_set_from (item, config_item_clone (new_), &e);
+ else if (item->schema->type != CONFIG_ITEM_STRING_ARRAY)
error_set (&e, "not a string array");
else if (add)
handle_command_set_add (item, new_->value.string.str, &e);
else if (remove)
handle_command_set_remove (item, new_->value.string.str, &e);
- else
- config_item_set_from (item, config_item_clone (new_), &e);
if (e)
{