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 3D8386DE034D for ; Sat, 8 Sep 2018 02:22:58 -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 OIiUL-lRFXls for ; Sat, 8 Sep 2018 02:22:57 -0700 (PDT) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 4E4956DE031B for ; Sat, 8 Sep 2018 02:22:57 -0700 (PDT) Received: by mail-wm0-f68.google.com with SMTP id t25-v6so16682073wmi.3 for ; Sat, 08 Sep 2018 02:22:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=to:subject:in-reply-to:references:from:date:message-id:mime-version; bh=FeR4hWx3MGuAHAiRKZi3SbFvrFqtc7gFMKj6L+hwAiY=; b=iYKxTeNyK+Qnm4D+GgnHkLAXZxemUSQTW+YqFzhePFkmYbNoMkQHH1C7c/cUka5SvK YUR3Fm88XfkvU4Th5xxm5l+8EnU+6WsXH3ELXyX1nD2FDnerRKNeuj1+6naX7bvQSOck zCaTbRCn6j4sghOLo/Vhb3vc0lOBVDjyadxElBzn+J3Ce/uiRR/fHgm0oGix+bEJ346m 7AdpC6X8m+4vuVxioED3NNRo3JG3FDXxyjTtUJsI29kM9+9Kk0d2xpbpiChgHaslz+D+ VPv4QfD8e+RMqq+/ENNc2f/foiXLHxoDOWZyf1IYRG2SCdIsBAW4AdC7V9tpc+Goov3a VQ5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:subject:in-reply-to:references:from:date :message-id:mime-version; bh=FeR4hWx3MGuAHAiRKZi3SbFvrFqtc7gFMKj6L+hwAiY=; b=qQM71eB1HNcQHOuzoQiM0SNPnCYJSJBxeFFW8CBwuc5TabXemUqGIlMXGRn1g0qjRC or5DsiwWWhdC27ZsXCXFk8RLUJg0RVXDgdUbPSDuhiqK7e+lkcUSH2LC8UvL0nPAOZu4 MgiiWKv+nbHFDyr9xBN0plvvWsAI/k07IahqsGaGLihLuVu7Va3EK7xw3oyggb0kToIe tC0b2SJRgWft9mR6hjvs4o/AsTjHYhchhOLJdvdux8hoZukHQldQGjqwMJenJdZRsS6A Rhx2tVfe4q9ufhZYbAKt9UfQY6iBsHMWKvsxDPh+Cdnw45bJD8IAEx5ClNvzqEvyAdGm 9XLQ== X-Gm-Message-State: APzg51BwiwWqbJGWp406hxfH0aSUWrldUuDw+DxM9CbNgHmh/tm2i8Au nw6VTb23moAZpvDhU2wH24FWhQ== X-Google-Smtp-Source: ANB0VdaLR0FvWx0bkOjUA9S8MhqFkTBCCGdTFFoFJfx2ciyDPiqipmLLUy7AkGYUrX/Sv5GYxXRZeQ== X-Received: by 2002:a1c:398b:: with SMTP id g133-v6mr7225396wma.5.1536398575360; Sat, 08 Sep 2018 02:22:55 -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 75-v6sm19513439wml.21.2018.09.08.02.22.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Sep 2018 02:22:54 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 7bb8ee5a; Sat, 8 Sep 2018 09:22:53 +0000 (UTC) To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH v1 2/2] notmuch: Database paths without a leading / are relative to $HOME In-Reply-To: <87o9d8j1bx.fsf@tethera.net> References: <20180825115756.24148-1-dme@dme.org> <20180825115756.24148-3-dme@dme.org> <87o9d8j1bx.fsf@tethera.net> X-HGTTG: constant-mown From: David Edmondson Date: Sat, 08 Sep 2018 10:22:53 +0100 Message-ID: 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 09:22:58 -0000 On Friday, 2018-09-07 at 21:10:42 -03, David Bremner wrote: > 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 I did think about that, but decided to follow existing practice in notmuch, which doesn't check: config->filename = talloc_asprintf (config, "%s/.notmuch-config", getenv ("HOME")); ...and... path = talloc_asprintf (config, "%s/mail", getenv ("HOME")); > configuration file (null)/.notmuch-config not found. > Try running 'notmuch setup' to create a configuration. dme. -- It's funny, I spent my whole life wanting to be talked about.