From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id D2C1E6DE00E6 for ; Fri, 7 Sep 2018 17:10:44 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.007 X-Spam-Level: X-Spam-Status: No, score=0.007 tagged_above=-999 required=5 tests=[AWL=0.008, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, T_SPF_HELO_TEMPERROR=0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QQuL6HpjET4y for ; Fri, 7 Sep 2018 17:10:44 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 148866DE00D1 for ; Fri, 7 Sep 2018 17:10:44 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1fyQpn-0004Hg-60; Fri, 07 Sep 2018 20:10:43 -0400 Received: (nullmailer pid 12511 invoked by uid 1000); Sat, 08 Sep 2018 00:10:42 -0000 From: David Bremner To: David Edmondson , notmuch@notmuchmail.org Subject: Re: [PATCH v1 2/2] notmuch: Database paths without a leading / are relative to $HOME In-Reply-To: <20180825115756.24148-3-dme@dme.org> References: <20180825115756.24148-1-dme@dme.org> <20180825115756.24148-3-dme@dme.org> Date: Fri, 07 Sep 2018 21:10:42 -0300 Message-ID: <87o9d8j1bx.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Sep 2018 00:10:44 -0000 David Edmondson writes: > If the database path specified in the configuration file does *not* > start with a /, presume that it is relative to $HOME and modify the > path used to open the database accordingly. > --- > notmuch-config.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/notmuch-config.c b/notmuch-config.c > index e1b16609..bf77cc9d 100644 > --- a/notmuch-config.c > +++ b/notmuch-config.c > @@ -660,7 +660,19 @@ _config_set_list (notmuch_config_t *config, > const char * > notmuch_config_get_database_path (notmuch_config_t *config) > { > - return _config_get (config, &config->database_path, "database", "path"); > + char *db_path = (char *)_config_get (config, &config->database_path, "database", "path"); > + > + if (db_path && *db_path != '/') { > + /* If the path in the configuration file begins with any > + * character other than /, presume that it is relative to > + * $HOME and update as appropriate. > + */ > + char *abs_path = talloc_asprintf (config, "%s/%s", getenv ("HOME"), db_path); > + talloc_free (db_path); > + db_path = config->database_path = abs_path; > + } In the unlikely event that HOME is not set, it would be nicer to print a message to that effect, rather than configuration file (null)/.notmuch-config not found. Try running 'notmuch setup' to create a configuration.