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 EDCF96DE092B for ; Sat, 8 Sep 2018 04:49:46 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.394 X-Spam-Level: X-Spam-Status: No, score=0.394 tagged_above=-999 required=5 tests=[AWL=-0.239, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001] 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 hY7S-073Mf9F for ; Sat, 8 Sep 2018 04:49:46 -0700 (PDT) Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by arlo.cworth.org (Postfix) with ESMTPS id EB7CA6DE091E for ; Sat, 8 Sep 2018 04:49:45 -0700 (PDT) Received: by mail-wm0-f49.google.com with SMTP id y139-v6so16924573wmc.2 for ; Sat, 08 Sep 2018 04:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=dlN6mxhGPMEzpBZj9jJcdxPP8UORVGOeRNEgpT+FIHs=; b=1IT9bWJilOp6UrErvBaxe77lVyzL0vDZMd9vhU0JWIeV7GI97GiJIMBTVF4Ejb1bSe cFS9fz1kPSZ+3aDsniCAjXUQwDbFyUVcZEBngUGrYENvAurVjIa66gLr7MuCzZPvfGtu cXTc37YuXcTfIhB7GBPlB0kgydUl1PBVN7QrqIMwDVSSSvluFv3ro55DyqZEOx4IIyl2 0HKPqbKwkBC2KUszSFIE6LvkaYh+rxaYWlF6mhjVUB1FHshHct5rSiU69xKDhVlL0meb R8t7xd9D2tAPDSMCiYO7s2T5MBzB/5RuD23+6NYxRO42tlJ+8oRtDEfKrHTip6/V/Azr oaOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=dlN6mxhGPMEzpBZj9jJcdxPP8UORVGOeRNEgpT+FIHs=; b=ddZJvNxmvTe6blY8D2nIbOUS5nHkAakLCUaqWb4gj+X/so96gyYgjWTQ5zHpxNp6lm 8n1GUnxVSR+h5sPbJlSlV8N1+4OycK5B6ve0A6StUC6f57yftHxlfhEGoEDOZ2dOFlXS +oJfkCoMFNrLMsi0RR6sJH8jt3FpkRIJvgg5HT7BAztbN/RksvR8bgTwMFwtAEgzxTTS mCCV4BVDrYgbdRWFTxYR+CKpKJyZ0Gi5TmLQjdyl4VJ2Ha+k7P5nsZk+UaPX5phMxK51 wXuRD3x4T6ocd/CetW9QDWgE9g7lGeul850kPkNkMNoVA7w09vQfh3jKMwbUoRGj/D7+ zFzQ== X-Gm-Message-State: APzg51DMIXLf3Qg/ES7DVF7tTjZgeBUdqCU3Sy4b9MBupru1devTJYR/ pVUKe0ex2xsHPeP620MhYpHgcGjWLMk= X-Google-Smtp-Source: ANB0Vdbyec4VIqzcDHyupmfo46je9imaJukhG2pdA9O0L6JCkI2gUe002rbvlV315NgEf8wbi2S/pg== X-Received: by 2002:a1c:c7c3:: with SMTP id x186-v6mr7866760wmf.109.1536407382547; Sat, 08 Sep 2018 04:49:42 -0700 (PDT) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by smtp.gmail.com with ESMTPSA id h7-v6sm8940393wrs.3.2018.09.08.04.49.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Sep 2018 04:49:41 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id f3fdd9ad for ; Sat, 8 Sep 2018 11:49:41 +0000 (UTC) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH v2 1/2] notmuch: Database paths without a leading / are relative to $HOME Date: Sat, 8 Sep 2018 12:49:40 +0100 Message-Id: <20180908114941.30501-1-dme@dme.org> X-Mailer: git-send-email 2.11.0 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 11:49:47 -0000 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; + } + + return db_path; } void -- 2.11.0