On Sun, Nov 29, 2020 at 05:37:43PM +0100, Andreas Grapentin wrote:
maybe the version XDG_CONFIG_HOME/isync/mbsyncrc makes sense, in case
any other utilities that are part of isync will provide config files in
the future?

i grok the argument, but i just don't think that this is going to happen given the track record of the last 25 years. in the worst case, we'd just support another fallback location. so XDG_CONFIG_HOME/mbsyncrc it is.

In the interest of granularity, I'll prepare a separate patch for that,
is that ok?

of course. it might make sense to squash in the end due to overlap, but for now let's work with separate patches.

speaking of possible overlap, you need to add a NEWS entry.

--- a/src/config.c
+++ b/src/config.c
@@ -331,17 +332,36 @@ load_config( const char *where )
        char buf[1024];

        if (!where) {
+               const char *config_home = getenv("XDG_CONFIG_HOME");
+               if (config_home)
+                       nfsnprintf( path, sizeof(path), "%s/" EXE "/config", 
config_home );
+               else
+                       nfsnprintf( path, sizeof(path), "%s/.config/" EXE 
"/config", Home );
                cfile.file = path;
+
+               info( "Reading configuration file %s\n", cfile.file );

let's move that below the final error handler - the error message is self-contained, and the operation itself takes microseconds. (listing the attempted locations would theoretically make sense as debug output, but i don't think this would actually serve a purpose in this context.)

+               cfile.fp = fopen( cfile.file, "r" );
+
+               if (!cfile.fp && errno == ENOENT) {

+                       errno = 0;

that's unnecessary - the next error would overwrite it anyway, and no sane code would rely on this being zero without resetting it immediately before.

+                       nfsnprintf( path, sizeof(path), "%s/." EXE "rc", Home );

+                       cfile.file = path;
+
that's also unnecessary, as the address didn't change.

+                       info( "Reading configuration file %s\n", cfile.file );
s.a.

+                       cfile.fp = fopen( cfile.file, "r" );
+               }
+       } else {
                cfile.file = where;

+               info( "Reading configuration file %s\n", cfile.file );
s.a.

+               cfile.fp = fopen( cfile.file, "r" );
+       }

+       if (!cfile.fp) {
+               sys_error( "Cannot open user config file '%s'", cfile.file );
                return 1;
        }


_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to