diff --git a/xC.c b/xC.c index 84c5532..50ddbcb 100644 --- a/xC.c +++ b/xC.c @@ -11361,7 +11361,7 @@ handle_command_set_modify return result; } -static void +static bool handle_command_set_assign_item (struct app_context *ctx, char *key, struct config_item *new_, bool add, bool remove) { @@ -11384,14 +11384,14 @@ handle_command_set_assign_item (struct app_context *ctx, log_global_error (ctx, "Failed to set option \"#s\": #s", key, e->message); error_free (e); + return false; } - else - { - struct strv tmp = strv_make (); - dump_matching_options (ctx->config.root, key, &tmp); - log_global_status (ctx, "Option changed: #s", tmp.vector[0]); - strv_free (&tmp); - } + + struct strv tmp = strv_make (); + dump_matching_options (ctx->config.root, key, &tmp); + log_global_status (ctx, "Option changed: #s", tmp.vector[0]); + strv_free (&tmp); + return true; } static bool @@ -11427,15 +11427,18 @@ handle_command_set_assign config_item_destroy (new_); return true; } + + bool changed = false; for (size_t i = 0; i < all->len; i++) { char *key = cstr_cut_until (all->vector[i], " "); - handle_command_set_assign_item (ctx, key, new_, add, remove); + if (handle_command_set_assign_item (ctx, key, new_, add, remove)) + changed = true; free (key); } config_item_destroy (new_); - if (get_config_boolean (ctx->config.root, "general.autosave")) + if (changed && get_config_boolean (ctx->config.root, "general.autosave")) save_configuration (ctx); return true; }