From: Thomas Schwinge <thomas_schwi...@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 <tho...@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)
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to