unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Thomas Schwinge <thomas@schwinge.name>
To: notmuch@notmuchmail.org
To: notmuch@notmuchmail.org
Cc: Thomas Schwinge <thomas@schwinge.name>
Subject: [PATCH] Properly quote Emacs' notmuch-command.
Date: Tue, 11 Jan 2011 13:02:07 +0100	[thread overview]
Message-ID: <1294747327-19430-1-git-send-email-thomas@schwinge.name> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3469 bytes --]

From: Thomas Schwinge <thomas_schwinge@mentor.com>

It happens that my notmuch-command may look like this:

    (setq notmuch-command "~/Mentor Graphics/command/notmuch")

Most of the times, notmuch-command is passed to call-process which will simply
do the right thing, but there are a few other cases where it is fed through the
shell and thus needs to be properly quoted / escaped.

I'm not entirely sure that shell-quote-wildcard-pattern is the correct function
to be used.  We can't use shell-quote-argument (which I first meant to use), as
that one will also escape the tilde (~).  Next idea was to first resolve the
tilde, and then use shell-quote-argument.  But I didn't find a suitable Emacs
function: we can't (unconditionally) use expand-file-name, as that one will
absolutize the filename: it will (wrongly) turn the default value `notmuch'
into `$CWD/notmuch'.

Signed-off-by: Thomas Schwinge <thomas@schwinge.name>

---

Hallo!

As stated above, if someone has (more Emacs knowledge and) a better
solution, please shout.

An additional item to conider: this solves the issue with tilde
expansion, but what about other shell magic like filename expansion
(globbing; which is what shell-quote-wildcard-pattern explicitly does
*not* quote / escape)?


Once we have determined what we actually want, is it OK to send a
testsuite patch to make it use such a ``nonstandard'' path, for catching
regressions early in the future?


Grüße,
 Thomas

 emacs/notmuch-lib.el  |    4 ++--
 emacs/notmuch-show.el |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index dd180ee..fdeb32b 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -61,7 +61,7 @@ the user hasn't set this variable with the old or new value."
   (let ((long-string
 	 ;; Trim off the trailing newline.
 	 (substring (shell-command-to-string
-		     (concat notmuch-command " --version"))
+		     (concat (shell-quote-wildcard-pattern notmuch-command) " --version"))
 		    0 -1)))
     (if (string-match "^notmuch\\( version\\)? \\(.*\\)$"
 		      long-string)
@@ -72,7 +72,7 @@ the user hasn't set this variable with the old or new value."
   "Return a value from the notmuch configuration."
   ;; Trim off the trailing newline
   (substring (shell-command-to-string
-	      (concat notmuch-command " config get " item))
+	      (concat (shell-quote-wildcard-pattern notmuch-command) " config get " item))
 	      0 -1))
 
 (defun notmuch-database-path ()
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 3a60d43..820f90f 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -957,12 +957,12 @@ than only the current message."
   (let (shell-command)
     (if entire-thread
 	(setq shell-command 
-	      (concat notmuch-command " show --format=mbox "
+	      (concat (shell-quote-wildcard-pattern notmuch-command) " show --format=mbox "
 		      (shell-quote-argument
 		       (mapconcat 'identity (notmuch-show-get-message-ids-for-open-messages) " OR "))
 		      " | " command))
       (setq shell-command
-	    (concat notmuch-command " show --format=raw "
+	    (concat (shell-quote-wildcard-pattern notmuch-command) " show --format=raw "
 		    (shell-quote-argument (notmuch-show-get-message-id)) " | " command)))
     (start-process-shell-command "notmuch-pipe-command" "*notmuch-pipe*" shell-command)))
 
-- 
tg: (b3caef1..) t/emcs-quote_notmuch-command (depends on: master)

                 reply	other threads:[~2011-01-11 18:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1294747327-19430-1-git-send-email-thomas@schwinge.name \
    --to=thomas@schwinge.name \
    --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).