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 6407F6DE01E4 for ; Sat, 25 Aug 2018 04:58:04 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.33 X-Spam-Level: X-Spam-Status: No, score=0.33 tagged_above=-999 required=5 tests=[AWL=-0.112, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.211, 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 7Jh2aHq3VxQF for ; Sat, 25 Aug 2018 04:58:03 -0700 (PDT) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by arlo.cworth.org (Postfix) with ESMTPS id 872D06DE0209 for ; Sat, 25 Aug 2018 04:58:03 -0700 (PDT) Received: by mail-wr1-f51.google.com with SMTP id z96-v6so9549868wrb.8 for ; Sat, 25 Aug 2018 04:58:03 -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:in-reply-to:references; bh=dlN6mxhGPMEzpBZj9jJcdxPP8UORVGOeRNEgpT+FIHs=; b=YJpCbM4gAgbA/Jr31IFWfmo/dvcpvvvXYDxU9O1qhM+Sq3VByABe7suaGCwQoqTOW0 AX5sxCzTch39u5C/rE0s8pi1uq4CofhBd087vZE7T9QulR+FsSjeLP9Pae79HCUjwQ3I BRm3X/xWkb5LUBmkOI9TGsaJYcDmrOs0VlKfybf6/RfGrhq+B9jDwNy634LXrLbEvbeS 4dTSn2Oc7PNjEWoJQmfaYYNrfekZew3vxh+qtxPvEz82G997mZ9/fLaQCHNoDdL8ZxbK eHpc2EcCHcIwaD/utJdnlF2X+05qVSy3TW+JM7TqZXsiEZzBi+I61SFsvCyGafTqItqF B4xw== 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:in-reply-to :references; bh=dlN6mxhGPMEzpBZj9jJcdxPP8UORVGOeRNEgpT+FIHs=; b=eX+QgdWMt6asO5YYyW9cl83qAVCTwLdFlBI0mUX8zsUc3/BR5OPr/L6BUJsRPnCYBh 0venOoKx3RHIQ8VBrNcVRQHth5qMahz+/FckbtQb6r9mvpQMyff6pWEIZEudK4u8MIwA 5NfSX8Cab3bl5LKWQwYyXRenit0W4dpWk7uB6Jt+syEBvMiQ7c8o4J6JvuVU2MXOaSpI 9AODhWvr4jAWtpShQOefcoP3X2I6JYin98hHilbPmD2vxu6HnCfJTIeCROQ0Rb5xv1qn xkdg0/O2qmVi3sbU9nCVZY1Ix35jLxt1vMDglC1l5VyZaCSIA7t/bdiKPmGPYQ9fNh/0 te9A== X-Gm-Message-State: APzg51AhlfjEklfeVLHeXbkkS5MVwD0EJTlVnBx9N+hEhtzyNn7HkRdr MbRdP93W5Jt3VWfPn3oD9XYOL42lvgnGgw== X-Google-Smtp-Source: ANB0VdYov291SqVyxjROZa7S3Z0/Mj+H7EuRIFiOrcBaCnAEpTZOfli7dinj9Kh1E7UfHXoeoRWqJg== X-Received: by 2002:adf:a211:: with SMTP id p17-v6mr3654973wra.196.1535198282120; Sat, 25 Aug 2018 04:58:02 -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 s205-v6sm4112235wmf.42.2018.08.25.04.57.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 04:58:00 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 5f12d487 for ; Sat, 25 Aug 2018 11:57:56 +0000 (UTC) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH v1 2/2] notmuch: Database paths without a leading / are relative to $HOME Date: Sat, 25 Aug 2018 12:57:56 +0100 Message-Id: <20180825115756.24148-3-dme@dme.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180825115756.24148-1-dme@dme.org> References: <20180825115756.24148-1-dme@dme.org> 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, 25 Aug 2018 11:58:04 -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