rfc for notmuch remote access script
Matt Armstrong
marmstrong at google.com
Thu Oct 27 14:37:14 PDT 2016
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 at 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.
More information about the notmuch
mailing list