Re: [PATCH] config: Expand ~ to $HOME
authorTomi Ollila <tomi.ollila@iki.fi>
Mon, 9 May 2016 07:54:21 +0000 (10:54 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:48 +0000 (16:21 -0700)
82/056afb67e7c5480420d0cc6a47fe5bc143ecb2 [new file with mode: 0644]

diff --git a/82/056afb67e7c5480420d0cc6a47fe5bc143ecb2 b/82/056afb67e7c5480420d0cc6a47fe5bc143ecb2
new file mode 100644 (file)
index 0000000..8bd6dad
--- /dev/null
@@ -0,0 +1,131 @@
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 75E5F6DE0022\r
+ for <notmuch@notmuchmail.org>; Mon,  9 May 2016 00:54:35 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.593\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.593 tagged_above=-999 required=5 tests=[AWL=-0.059,\r
+  SPF_NEUTRAL=0.652] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id AGIziLZNsACB for <notmuch@notmuchmail.org>;\r
+ Mon,  9 May 2016 00:54:26 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id A22BA6DE0005\r
+ for <notmuch@notmuchmail.org>; Mon,  9 May 2016 00:54:25 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id D59A21000B3;\r
+ Mon,  9 May 2016 10:54:21 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Bijan Chokoufe <bijan@chokoufe.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] config: Expand ~ to $HOME\r
+In-Reply-To:\r
+ <CAOsAL0pp+3b-sf_k5kdrN7r1W8EtkC2vJ44Mg-e+su-8V=H6bQ@mail.gmail.com>\r
+References: <1462722574-4176-1-git-send-email-bijan@chokoufe.com>\r
+ <m2r3dc7azk.fsf@guru.guru-group.fi>\r
+ <CAOsAL0pp+3b-sf_k5kdrN7r1W8EtkC2vJ44Mg-e+su-8V=H6bQ@mail.gmail.com>\r
+References: <1462722574-4176-1-git-send-email-bijan@chokoufe.com>\r
+ <m2r3dc7azk.fsf@guru.guru-group.fi>\r
+ <CAOsAL0pp+3b-sf_k5kdrN7r1W8EtkC2vJ44Mg-e+su-8V=H6bQ@mail.gmail.com>\r
+User-Agent: Notmuch/0.22+9~gb26b5ad (http://notmuchmail.org) Emacs/24.5.1\r
+ (x86_64-unknown-linux-gnu)\r
+User-Agent: Notmuch/0.22+9~gb26b5ad (http://notmuchmail.org) Emacs/24.5.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Mon, 09 May 2016 10:54:21 +0300\r
+Message-ID: <m21t5bll8y.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 09 May 2016 07:54:35 -0000\r
+\r
+On Sun, May 08 2016, Bijan Chokoufe <bijan@chokoufe.com> wrote:\r
+\r
+> Hi Tomi,\r
+>\r
+> Thanks for your detailled review. Please see questions below.\r
+>\r
+> Cheers,\r
+> Bijan\r
+>\r
+> Tomi Ollila <tomi.ollila@iki.fi> schrieb am So., 8. Mai 2016 um 18:47 Uhr:\r
+>\r
+>> On Sun, May 08 2016, Bijan Chokoufe Nejad <bijan@chokoufe.com> wrote:\r
+>>\r
+>> > Very useful in case you want to keep your .notmuch-config synchronized\r
+>> across\r
+>> > machines where you have different user names.\r
+>>\r
+>> Thank you for your interest in improving notmuch!\r
+>>\r
+>> There are a few things that needs to be sorted out for this feature to be\r
+>> good:\r
+>>\r
+>> This implementation does not handle ~user/ prefix: i.e. home directory of\r
+>> 'user' (maybe this should not, but it should handle the case).\r
+>\r
+> I don't get it. Is '~user" an alternative to '~'?\r
+\r
+~user is ~ in case you're 'user' -- except that now that I think of it\r
+~user could read home directory from /etc/passwd and not using $HOME.\r
+If you're 'eve', then ~alice should definitely be different than ~\r
+\r
+>\r
+>> Whether or not ~user is handled, it should check that slash (/) follows...\r
+>>\r
+>>\r
+> So I guess you aim at the case where someone sets `path=~`? On the other\r
+> hand why is this checking not necessary in the "normal" case where no\r
+> expanding of `~` is done? Or is it maybe already handled in\r
+> `lib/database.cc`. Just to be clear I tested that it works currently with\r
+> `path=~/.mail`.\r
+\r
+your code checked that path[0] == '~', but nothing else, e.g.\r
+\r
+~123randomstuff/... would expand as /home/user23randomstuff/... \r
+\r
+... and you have good point path being set as single '~' !\r
+\r
+>> IIRC there is some ready-made implementations of the above -- but if not,\r
+>> one option is to check how (expand-file-name) works in emacs for reference.\r
+>>\r
+>>\r
+> Well there is wordexp (http://linux.die.net/man/3/wordexp) but I wasn't\r
+> sure if I should use it. The getenv just seemed simpler but maybe it is\r
+> necessary.\r
+\r
+For the time being we could simply do checking that path[0] == '~' and\r
+path[1] == '/' and then do expansion based on getenv ("HOME") -- and\r
+comment that ~any_user is just not supported there.\r
+\r
+>From testing point of view doing one positive test which ensures that when\r
+HOME is a string pointing to valid directory (and does not end with\r
+trailing slash as it usually is) and path in configuration starts with '~/'\r
+(and does not have multiple slashes following) works as expected...\r
+\r
+(as a special case, from softare functionality point I don't see problem\r
+setting path=~/ but from usability point that might not be the best -- but\r
+some users may have peculiar preferences... ;D)\r
+\r
+Tomi\r