unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Matt Armstrong <marmstrong@google.com>
To: Tomi Ollila <domo141@gmail.com>, notmuch@notmuchmail.org
Subject: Re: rfc for notmuch remote access script
Date: Thu, 27 Oct 2016 14:37:14 -0700	[thread overview]
Message-ID: <qf5bmy5qxrp.fsf@marmstrong-linux.kir.corp.google.com> (raw)
In-Reply-To: <87lgx9ln56.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-tickle-me>

Neat.  Basics of it look correct to me.  Personally, I'd abandon most of
these environment variables and edit the script directly, but that goes
against your stated goal.

Other comments below.


Tomi Ollila <domo141@gmail.com> writes:

> Hi
>
> j4ni on irc expressed interest of having an installation option for
> notmuch-emacs and a notmuch remote access script as 'notmuch'
>
> This got me thinking what kind of script would fulfill all the needs
> that I know of.
>
> and this is the result of that:
>
> --8<----8<----8<----8<----8<----8<----8<----8<--
>
> #!/bin/bash
>
> set -euf
>
> if [ "${NOTMUCH_REMOTE_XTRACE_FILE-}" ]; then

In bash, I often see people favoring this style:

if [[ -n ${NOTMUCH_REMOTE_XTRACE_FILE-} ]]; then


> 	exec 6>>"$NOTMUCH_REMOTE_XTRACE_FILE"
> 	BASH_XTRACEFD=6
> 	echo -- >&6
> 	set -x
> 	env >&6

This BASH_XTRACEFD stuff is nice, and the technique is new to me.  Is
there a way to close the trace file descriptor so it isn't available to
the ssh command?  Maybe something like this works?

exec 6>&- "$NOTMUCH_REMOTE_SSH_COMMAND" $NOTMUCH_REMOTE_SSH_ARGS \
  "$NOTMUCH_REMOTE_HOST" $NOTMUCH_REMOTE_COMMAND $ARGS

(though that only needs to happen optionally, which makes it tricky).

> : ${NOTMUCH_REMOTE_SSH_COMMAND:=ssh}
> : ${NOTMUCH_REMOTE_SSH_ARGS=}
> : ${NOTMUCH_REMOTE_HOST:=notmuch}
> : ${NOTMUCH_REMOTE_COMMAND:=notmuch}
>
> printf -v ARGS '%q ' "$@"

This is the real secret sauce.  When I was looking at removing the
extraneous quoting we have in notmuch-show.el, it boiled down to
figuring this out.  The web has a lot of people asking how to do this
properly, but very few good answers.

  reply	other threads:[~2016-10-27 21:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-27 17:25 rfc for notmuch remote access script Tomi Ollila
2016-10-27 21:37 ` Matt Armstrong [this message]
2016-10-30 21:31   ` Tomi Ollila
2016-10-28  6:42 ` Jani Nikula
2016-10-28 10:35   ` David Bremner
2016-10-30  9:35     ` Jani Nikula
2016-10-30 11:34       ` David Bremner
2016-10-30 12:39         ` Mark Walters
2016-10-30 14:36           ` Jani Nikula
2016-10-30 15:52           ` David Bremner
2016-11-04 18:54         ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=qf5bmy5qxrp.fsf@marmstrong-linux.kir.corp.google.com \
    --to=marmstrong@google.com \
    --cc=domo141@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).