[PATCH] test: cli: getting/setting/removing config values
Pieter Praet
pieter at praet.org
Mon Jan 16 02:31:11 PST 2012
On Sat, 14 Jan 2012 08:16:30 -0400, David Bremner <david at tethera.net> wrote:
> On Sat, 14 Jan 2012 09:57:56 +0100, Pieter Praet <pieter at praet.org> 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
More information about the notmuch
mailing list