rfc for notmuch remote access script
Tomi Ollila
domo141 at gmail.com
Sun Oct 30 14:31:23 PDT 2016
Thanks for the discussion so far. after sending this email I continue
tomorrow with the others...
Matt Armstrong <marmstrong at google.com> writes:
> 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.
In this case yes... the goal being me having a chance to drop one of
my scripts from the pool...
> Other comments below.
>
>>
>> if [ "${NOTMUCH_REMOTE_XTRACE_FILE-}" ]; then
>
> In bash, I often see people favoring this style:
>
> if [[ -n ${NOTMUCH_REMOTE_XTRACE_FILE-} ]]; then
That is a non-mandatory posix shell feature, works in bash, ksh, zsh
(and possibly in busybox shell), but not in dash. to share code snippets
between all shells rather use more portable syntax (and my personal
preference is `if test "${var-}"\n then ... fi`))
( as as side note, in some systems there is /bin/[[ -- that is just plain
stupid !!! ;/ it cannot possibly handle the syntax builtin [[ accepts )
>> 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
that is good question. in case of ssh having 6 is not a problem -- the
fd 6 is not available in remote host (and it is just for investigating
problems) . but for the interested, something like this would work here
(just that there is extra x in the output ;/):
x () { exec 6>&-; "$@"; }
x exec ...
>
> (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.
... and the problem with e.g. stack overflow is that without karma one
cannot answer there...
More information about the notmuch
mailing list