Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B6C0A431E62 for ; Mon, 16 Jan 2012 02:33:02 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id igpaGb5gTAHX for ; Mon, 16 Jan 2012 02:33:02 -0800 (PST) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E74BB431FC0 for ; Mon, 16 Jan 2012 02:33:01 -0800 (PST) Received: by werh12 with SMTP id h12so1292874wer.26 for ; Mon, 16 Jan 2012 02:33:00 -0800 (PST) Received: by 10.180.93.168 with SMTP id cv8mr13533569wib.2.1326709980847; Mon, 16 Jan 2012 02:33:00 -0800 (PST) Received: from localhost ([109.131.75.86]) by mx.google.com with ESMTPS id em13sm11390801wid.7.2012.01.16.02.32.59 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jan 2012 02:33:00 -0800 (PST) From: Pieter Praet To: David Bremner Subject: Re: [PATCH] test: cli: getting/setting/removing config values In-Reply-To: <87aa5qjx7l.fsf@zancas.localnet> References: <8739bir7do.fsf@praet.org> <1326531476-14556-1-git-send-email-pieter@praet.org> <87aa5qjx7l.fsf@zancas.localnet> User-Agent: Notmuch/0.11+78~g6c58370 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-unknown-linux-gnu) Date: Mon, 16 Jan 2012 11:31:11 +0100 Message-ID: <874nvw2b2o.fsf@praet.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Notmuch Mail X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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, 16 Jan 2012 10:33:02 -0000 On Sat, 14 Jan 2012 08:16:30 -0400, David Bremner wrote: > On Sat, 14 Jan 2012 09:57:56 +0100, Pieter Praet wrote: > > Full test coverage for getting, setting and removing options in > > notmuch(1)'s config file ($NOTMUCH_CONFIG or $HOME/.notmuch-config). > > > > --- > > + > > +# FIXME: Not the most robust nor portable solution here... > > +# Especially `hostname --domain' may have unwanted effects on > > +# some platforms, e.g. setting your hostname to "--domain" ;) > > +fallback_name="$(grep $(id -un) /etc/passwd | cut -d ":" -f 5 | cut -d "," -f 1)" > > +fallback_email="$(id -un)@$(hostname).$(hostname --domain)" > > I'm not sure how portable it is, but maybe dnsdomainname would at least > have better failure modes. > Hmmm, `dnsdomainname' returns "(none)" here; Does it work for you? Running `domainname' instead seems to do the right thing though... It would probably be safest to simply mirror how it's done @ notmuch-config.c:313, but that seems rather excessive. > I also wondered about using getent instead of grep. > Agreed, much safer; `grep' might return multiple results. > d How about this? : #+begin_src sh fallback_name="$(getent passwd ${USER} | cut -d ":" -f 5 | cut -d "," -f 1)" test -n "${EMAIL}" \ && fallback_email="${EMAIL}" \ || fallback_email="${USER}@$(hostname).$(domainname)" #+end_src Peace -- Pieter