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 484666DE0AD1 for ; Sat, 8 Sep 2018 07:28:19 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.469 X-Spam-Level: X-Spam-Status: No, score=0.469 tagged_above=-999 required=5 tests=[AWL=-0.183, SPF_NEUTRAL=0.652] 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 D1gGZIVFsLZf for ; Sat, 8 Sep 2018 07:28:18 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by arlo.cworth.org (Postfix) with ESMTP id 8E55D6DE0AAB for ; Sat, 8 Sep 2018 07:28:18 -0700 (PDT) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id EE8BE10008E; Sat, 8 Sep 2018 17:28:10 +0300 (EEST) From: Tomi Ollila To: David Edmondson , notmuch@notmuchmail.org Subject: Re: [PATCH v2 1/2] notmuch: Database paths without a leading / are relative to $HOME In-Reply-To: <20180908114941.30501-1-dme@dme.org> References: <20180908114941.30501-1-dme@dme.org> User-Agent: Notmuch/0.27+14~ge594ae3 (https://notmuchmail.org) Emacs/25.2.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ 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 14:28:19 -0000 On Sat, Sep 08 2018, David Edmondson wrote: > 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. Series LGTM. Looked previous discussion, thought about using /etc/passwd but $HOME is more flexible. Did not test, though... Tomi > --- > 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; > + } > + > + return db_path; > } > > void > -- > 2.11.0 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch