unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Matt Armstrong <marmstrong@google.com>
To: notmuch@notmuchmail.org
Subject: [PATCH] emacs: notmuch-show: remove extraneous shell quoting
Date: Tue, 13 Sep 2016 23:17:15 -0700	[thread overview]
Message-ID: <1473833835-17208-1-git-send-email-marmstrong@google.com> (raw)

Remove shell quoting from notmuch-show--build-buffer.  The args list
is ultimately passed to call-process, which passes them verbatim to
the subprocess (typically, notmuch).  The quoting, intended for a
shell, are unnecessary and confusing.

This code originally appeared in
9193455fa1476ea3957475e77379b75efa6dd90b, aiming to support remote
notmuch execution over ssh.  The commit message included this example
shell script (simplified):

  #!/bin/sh
  ssh remotehost notmuch $@

That script doesn't properly quote "$@".  Even if it did, it wouldn't
work because the shell ssh starts on the remote host does another
round of shell word splitting.  Fortunately, notmuch already provides
an example of a correct shell script on
https://notmuchmail.org/remoteusage/ (again simplified):

  #!/bin/bash
  printf -v ARGS "%q " "$@"
  ssh remotehost notmuch $ARGS

With the above script I'm able to use notmuch in "remote" mode.
Quoted search terms work as expected, etc.

(this is my t/remote-quoting)

---
 emacs/notmuch-show.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5a585f3..da2d685 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1267,9 +1267,9 @@ first relevant message.
 If no messages match the query return NIL."
   (let* ((basic-args (list notmuch-show-thread-id))
 	 (args (if notmuch-show-query-context
-		   (append (list "\'") basic-args
-			   (list "and (" notmuch-show-query-context ")\'"))
-		 (append (list "\'") basic-args (list "\'"))))
+		   (append basic-args
+			   (list "and (" notmuch-show-query-context ")"))
+		 basic-args))
 	 (cli-args (cons "--exclude=false"
 			 (when notmuch-show-elide-non-matching-messages
 			   (list "--entire-thread=false"))))
-- 
tg: (89c8d27..) t/remote-quoting (depends on: master)

             reply	other threads:[~2016-09-14  6:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-14  6:17 Matt Armstrong [this message]
2016-09-14  6:28 ` [PATCH] emacs: notmuch-show: remove extraneous shell quoting Matt Armstrong
  -- strict thread matches above, loose matches on Subject: below --
2016-09-14  6:20 Matt Armstrong
2016-09-14  9:51 ` Tomi Ollila
2016-09-16  6:07 ` Matt Armstrong
2016-09-16 19:36   ` Mark Walters
2016-09-16 23:22     ` Matt Armstrong
2016-09-16 20:44   ` Tomi Ollila

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=1473833835-17208-1-git-send-email-marmstrong@google.com \
    --to=marmstrong@google.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).