From ba71b62b7fdc37846cb511a4b66f79bb6e002048 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Mon, 9 May 2016 10:54:21 +0300 Subject: [PATCH] Re: [PATCH] config: Expand ~ to $HOME --- 82/056afb67e7c5480420d0cc6a47fe5bc143ecb2 | 131 ++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 82/056afb67e7c5480420d0cc6a47fe5bc143ecb2 diff --git a/82/056afb67e7c5480420d0cc6a47fe5bc143ecb2 b/82/056afb67e7c5480420d0cc6a47fe5bc143ecb2 new file mode 100644 index 000000000..8bd6dadf3 --- /dev/null +++ b/82/056afb67e7c5480420d0cc6a47fe5bc143ecb2 @@ -0,0 +1,131 @@ +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 75E5F6DE0022 + for ; Mon, 9 May 2016 00:54:35 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: 0.593 +X-Spam-Level: +X-Spam-Status: No, score=0.593 tagged_above=-999 required=5 tests=[AWL=-0.059, + SPF_NEUTRAL=0.652] 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 AGIziLZNsACB for ; + Mon, 9 May 2016 00:54:26 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id A22BA6DE0005 + for ; Mon, 9 May 2016 00:54:25 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id D59A21000B3; + Mon, 9 May 2016 10:54:21 +0300 (EEST) +From: Tomi Ollila +To: Bijan Chokoufe , notmuch@notmuchmail.org +Subject: Re: [PATCH] config: Expand ~ to $HOME +In-Reply-To: + +References: <1462722574-4176-1-git-send-email-bijan@chokoufe.com> + + +References: <1462722574-4176-1-git-send-email-bijan@chokoufe.com> + + +User-Agent: Notmuch/0.22+9~gb26b5ad (http://notmuchmail.org) Emacs/24.5.1 + (x86_64-unknown-linux-gnu) +User-Agent: Notmuch/0.22+9~gb26b5ad (http://notmuchmail.org) Emacs/24.5.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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: Mon, 09 May 2016 07:54:35 -0000 + +On Sun, May 08 2016, Bijan Chokoufe wrote: + +> Hi Tomi, +> +> Thanks for your detailled review. Please see questions below. +> +> Cheers, +> Bijan +> +> Tomi Ollila schrieb am So., 8. Mai 2016 um 18:47 Uhr: +> +>> On Sun, May 08 2016, Bijan Chokoufe Nejad wrote: +>> +>> > Very useful in case you want to keep your .notmuch-config synchronized +>> across +>> > machines where you have different user names. +>> +>> Thank you for your interest in improving notmuch! +>> +>> There are a few things that needs to be sorted out for this feature to be +>> good: +>> +>> This implementation does not handle ~user/ prefix: i.e. home directory of +>> 'user' (maybe this should not, but it should handle the case). +> +> I don't get it. Is '~user" an alternative to '~'? + +~user is ~ in case you're 'user' -- except that now that I think of it +~user could read home directory from /etc/passwd and not using $HOME. +If you're 'eve', then ~alice should definitely be different than ~ + +> +>> Whether or not ~user is handled, it should check that slash (/) follows... +>> +>> +> So I guess you aim at the case where someone sets `path=~`? On the other +> hand why is this checking not necessary in the "normal" case where no +> expanding of `~` is done? Or is it maybe already handled in +> `lib/database.cc`. Just to be clear I tested that it works currently with +> `path=~/.mail`. + +your code checked that path[0] == '~', but nothing else, e.g. + +~123randomstuff/... would expand as /home/user23randomstuff/... + +... and you have good point path being set as single '~' ! + +>> IIRC there is some ready-made implementations of the above -- but if not, +>> one option is to check how (expand-file-name) works in emacs for reference. +>> +>> +> Well there is wordexp (http://linux.die.net/man/3/wordexp) but I wasn't +> sure if I should use it. The getenv just seemed simpler but maybe it is +> necessary. + +For the time being we could simply do checking that path[0] == '~' and +path[1] == '/' and then do expansion based on getenv ("HOME") -- and +comment that ~any_user is just not supported there. + +>From testing point of view doing one positive test which ensures that when +HOME is a string pointing to valid directory (and does not end with +trailing slash as it usually is) and path in configuration starts with '~/' +(and does not have multiple slashes following) works as expected... + +(as a special case, from softare functionality point I don't see problem +setting path=~/ but from usability point that might not be the best -- but +some users may have peculiar preferences... ;D) + +Tomi -- 2.26.2