Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 8FF0B6DE00EB for ; Sun, 8 May 2016 08:50:06 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.47 X-Spam-Level: X-Spam-Status: No, score=-0.47 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-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 IrETlqkOY2w4 for ; Sun, 8 May 2016 08:49:57 -0700 (PDT) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id CAAA56DE0022 for ; Sun, 8 May 2016 08:49:56 -0700 (PDT) Received: by mail-wm0-f66.google.com with SMTP id w143so16747169wmw.3 for ; Sun, 08 May 2016 08:49:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=Ul8eytKlozsYZyVbm9I2bHygmkFi2wYK7vsUqwQW7Js=; b=o9QU/3dq92/SR3DGHKBh/eDxZ/iiZ3qGVEEngbSVFBfc1t2TYAQDM1i74sKZKxluLl rQA7jEvPcs6R4AVohwVpMGfpg+69tpySZHgkz4Vv2zTQN5blshfBNfY0jW8Z/YSCbOYK ZEtVCjoZsOnnjkno1Y4um6IiepUVW/VCfxLX5aD81muAbSSLOgt4RykGBxL/DcqtdHZl FFa+KGxU2OeT8z4E7AO3k9jkB3UjkA3cP8kuOuh67NS43ri/VRYuan8h9HvUJ4KQZmtJ lJ2zIKUjwtNllK58TFRYzaB+YfdbXooE9n32N90CDVjFKP7oahxOHlRWRVwETl1enP/J InHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=Ul8eytKlozsYZyVbm9I2bHygmkFi2wYK7vsUqwQW7Js=; b=VX+kMVnnmXsLk3nXnu+m/4mnU0eqLi5colL4cnEdPi+/qxsKQkeDTnYEqcf3zBmYyU VBLKnA+lHJGvZWlabKYtARoX9Z0wXs8iRe4c/PrhJYkTv79vUGw1kpuyJzgNdT47uEmM 6lI6z7u2ZknsooBL6+LMVLmmEYLd06VHaJHKPQM6uUyLOA64rvMw8P5I4VPbLUXd6Ho8 OvKXMWImUXK4DyHoqTo90oZp7k3NYcWi+uxsTMq35xxc5oD+yHuXfRlKOl/mLrurjhJV OFO+GJfaW+joTwT1H2t/yB7S5QxvyvWfxt7ovMOSTCObYJa5xF9jMUJgcXtyGLHLqWpN XliA== X-Gm-Message-State: AOPr4FWtjrBA7z5CZyLMt1iZfSWFEr7zTQambNnAzQoFGL9Blp4NMp2hpKJ0kGgeKfxlOA== X-Received: by 10.194.114.100 with SMTP id jf4mr28087233wjb.55.1462722595025; Sun, 08 May 2016 08:49:55 -0700 (PDT) Received: from localhost.localdomain (ip5f5be327.dynamic.kabel-deutschland.de. [95.91.227.39]) by smtp.gmail.com with ESMTPSA id lr9sm8040308wjb.39.2016.05.08.08.49.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 May 2016 08:49:54 -0700 (PDT) Sender: Bijan Chokoufe From: Bijan Chokoufe Nejad To: notmuch@notmuchmail.org Subject: [PATCH] config: Expand ~ to $HOME Date: Sun, 8 May 2016 17:49:34 +0200 Message-Id: <1462722574-4176-1-git-send-email-bijan@chokoufe.com> X-Mailer: git-send-email 1.9.1 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.20 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: Sun, 08 May 2016 15:50:06 -0000 Very useful in case you want to keep your .notmuch-config synchronized across machines where you have different user names. --- Not sure this is completely plattform independent. I also don't know how to implement a unit test for this. --- notmuch-config.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/notmuch-config.c b/notmuch-config.c index d252bb2..c9f26ef 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -605,7 +605,16 @@ _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"); + const char* path = _config_get (config, &config->database_path, "database", "path"); + if (path != NULL && path[0] == '~') { + char *home_path = getenv("HOME"); + char *shortened_path = malloc( sizeof(char) * ( strlen (path) - 1 ) ); + strncpy(shortened_path, path + 2, strlen(path)); + return talloc_asprintf (NULL, "%s/%s", home_path, shortened_path); + } + else { + return path; + } } void -- 1.9.1