From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 3B2256DE0318 for ; Thu, 27 Oct 2016 14:37:18 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.464 X-Spam-Level: X-Spam-Status: No, score=-0.464 tagged_above=-999 required=5 tests=[AWL=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.211, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WJn4D2t_9xyd for ; Thu, 27 Oct 2016 14:37:17 -0700 (PDT) Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by arlo.cworth.org (Postfix) with ESMTPS id A291C6DE02DD for ; Thu, 27 Oct 2016 14:37:17 -0700 (PDT) Received: by mail-pf0-f179.google.com with SMTP id s8so24344959pfj.2 for ; Thu, 27 Oct 2016 14:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=8U9GYhlcki1t3mXG0S6zlyYcPJoi/eMA/ddsCtpCosA=; b=iX84ArIa4LWc35xZqQloDnl5KATn8POTCCIJUPpgOTWAfr/PPur1J/5L6/FLftfmsT eUgBLfOecFxWY9uzQsqFW/yY9QvEXcEMwIYlQe/Ag5XCwxttI9I9E+ZkMrj0iIC+Pt7o GZFfXeN7IjYp/TFMk444TZoLiRMvv5ozJJUvhKpKDK5at13fs71PvBjIKiWhhgu7ehI7 qKZogtyZGR7a2y7bm0gDr2YPx4DlJM6NQR9RwQ8AuAC1DM2gypnqSW5A6XT4cztkAQhP WlVazJkAz40F4TdkE5mrn6a0LcgZ0r7ySAFMOcKOJZ3SbhRZi7ZlngHMniOG96um9GTE q/jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=8U9GYhlcki1t3mXG0S6zlyYcPJoi/eMA/ddsCtpCosA=; b=RXP9OIiXZwJnsClP/pDolXUAzy7Kclj89t19xX6NnnyJvSGHD8xWgVvwBKf0s/EA86 Q4Q5DGNUDT2IfYxsC9xLF/msMwO2DdzAnM2fpaf0Dx7HTl5H8rUTZ1RDU4myvuH+g0ym /m5sYYZ9wN+YY1gBv0Qt5ZvZXv18DVk1iHFnoIfyoqg/tBO+vrhJxq8i7VJiltvYgmbo R2SMGIp/3xoN1sjDbzkZskLYE+R8mTXXRMAOwdFMoole+CTEE0z/N0V5Xwhkl9HmK9q9 eSrvVXsoCgbD/0Ap4dhHvk7VGUnz8N7TbMSIxSUwxIAQDLx8N1SHGOmz2H/HRMCU35SV vKxA== X-Gm-Message-State: ABUngvdjECZ4rA4lD8VXYuYG1vQHCaufM5k8pG/3cSDnAdcUdVBvMXnJ8HTletdUXM6WUCXE X-Received: by 10.98.129.130 with SMTP id t124mr18229780pfd.5.1477604235798; Thu, 27 Oct 2016 14:37:15 -0700 (PDT) Received: from marmstrong-linux.kir.corp.google.com ([2620:0:1008:11:fd42:15d1:3d5c:c5f]) by smtp.gmail.com with ESMTPSA id yi2sm13895323pab.17.2016.10.27.14.37.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Oct 2016 14:37:14 -0700 (PDT) From: Matt Armstrong To: Tomi Ollila , notmuch@notmuchmail.org Subject: Re: rfc for notmuch remote access script In-Reply-To: <87lgx9ln56.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-tickle-me> References: <87lgx9ln56.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-tickle-me> Date: Thu, 27 Oct 2016 14:37:14 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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: Thu, 27 Oct 2016 21:37:18 -0000 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 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.