From ca6a86c6456d7fce2f18da8ec92d6d7ff14dc5f8 Mon Sep 17 00:00:00 2001 From: Bijan Chokoufe Nejad Date: Sun, 8 May 2016 15:47:50 +0200 Subject: [PATCH v2] config: Expand ~ to $HOME Very useful in case you want to keep your .notmuch-config synchronized across machines where you have different user names. --- Check for '~/' instead of checking for '~' and fix memory issue. Unit test is still pending --- notmuch-config.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/notmuch-config.c b/notmuch-config.c index d252bb2..e97d5b0 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -605,7 +605,15 @@ _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"); + /* '~user/some/path' is not supported but only '~/some/path' */ + if (path != NULL && path[0] == '~' && path[1] == '/') { + char *home_path = getenv("HOME"); + return talloc_asprintf (NULL, "%s/%s", home_path, path + 2); + } + else { + return path; + } } void -- 1.9.1