From 483ab39e3ca9033aaca83ccd2c17d4a59fd4fa76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Sat, 23 Jul 2016 20:00:40 +0200 Subject: [PATCH] degesch: die on configuration parse errors Seems more sensible. --- degesch.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/degesch.c b/degesch.c index 1d6e597..f394a3c 100644 --- a/degesch.c +++ b/degesch.c @@ -12683,7 +12683,7 @@ load_configuration_file (const char *filename, struct error **e) struct error *error = NULL; if (!(root = config_item_parse (data.str, data.len, false, &error))) { - error_set (e, "Configuration parse error: %s", error->message); + error_set (e, "Parsing `%s' failed: %s", filename, error->message); error_free (error); } end: @@ -12744,6 +12744,10 @@ load_default_aliases (struct app_context *ctx) static void load_configuration (struct app_context *ctx) { + // In theory, we could ensure that only one instance is running by locking + // the configuration file and ensuring here that it exists. This is + // however brittle, as it may be unlinked without the application noticing. + struct config_item *root = NULL; struct error *e = NULL; @@ -12758,11 +12762,10 @@ load_configuration (struct app_context *ctx) if (e) { log_global_error (ctx, "#s", e->message); + log_global_error (ctx, + "Please either fix the configuration file or remove it", filename); error_free (e); - - // That would be somewhat undesired - config_item_get (ctx->config.root, "behaviour.save_on_quit", NULL) - ->value.boolean = false; + exit (EXIT_FAILURE); } if (root)