1 Return-Path: <thomas@schwinge.name>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 219C242D2A5
\r
6 for <notmuch@notmuchmail.org>; Tue, 11 Jan 2011 10:09:35 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "To"
\r
12 X-Spam-Status: No, score=0 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id 2jbd8COwdmJx for <notmuch@notmuchmail.org>;
\r
17 Tue, 11 Jan 2011 10:09:31 -0800 (PST)
\r
18 Received: from smtprelay02.ispgateway.de (smtprelay02.ispgateway.de
\r
20 by olra.theworths.org (Postfix) with ESMTP id CABE842D28A
\r
21 for <notmuch@notmuchmail.org>; Tue, 11 Jan 2011 10:09:30 -0800 (PST)
\r
22 Received: from [87.180.67.225] (helo=stokes.schwinge.homeip.net)
\r
23 by smtprelay02.ispgateway.de with esmtpa (Exim 4.68)
\r
24 (envelope-from <thomas@schwinge.name>) id 1Pciev-0002Km-LR
\r
25 for notmuch@notmuchmail.org; Tue, 11 Jan 2011 19:09:29 +0100
\r
26 Received: (qmail 21438 invoked from network); 11 Jan 2011 18:09:07 -0000
\r
27 Received: from unknown (192.168.111.252)
\r
28 by stokes.schwinge.homeip.net with QMQP; 11 Jan 2011 18:09:07 -0000
\r
29 Received: (nullmailer pid 19463 invoked by uid 1000);
\r
30 Tue, 11 Jan 2011 12:02:14 -0000
\r
31 From: Thomas Schwinge <thomas@schwinge.name>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [PATCH] Properly quote Emacs' notmuch-command.
\r
34 Date: Tue, 11 Jan 2011 13:02:07 +0100
\r
35 Message-Id: <1294747327-19430-1-git-send-email-thomas@schwinge.name>
\r
36 X-Mailer: git-send-email 1.7.1
\r
37 To: notmuch@notmuchmail.org
\r
38 X-Df-Sender: thomas@schwinge.name
\r
39 Cc: Thomas Schwinge <thomas@schwinge.name>
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\r
43 List-Id: "Use and development of the notmuch mail system."
\r
44 <notmuch.notmuchmail.org>
\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
48 List-Post: <mailto:notmuch@notmuchmail.org>
\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
52 X-List-Received-Date: Tue, 11 Jan 2011 18:09:35 -0000
\r
54 From: Thomas Schwinge <thomas_schwinge@mentor.com>
\r
56 It happens that my notmuch-command may look like this:
\r
58 (setq notmuch-command "~/Mentor Graphics/command/notmuch")
\r
60 Most of the times, notmuch-command is passed to call-process which will simply
\r
61 do the right thing, but there are a few other cases where it is fed through the
\r
62 shell and thus needs to be properly quoted / escaped.
\r
64 I'm not entirely sure that shell-quote-wildcard-pattern is the correct function
\r
65 to be used. We can't use shell-quote-argument (which I first meant to use), as
\r
66 that one will also escape the tilde (~). Next idea was to first resolve the
\r
67 tilde, and then use shell-quote-argument. But I didn't find a suitable Emacs
\r
68 function: we can't (unconditionally) use expand-file-name, as that one will
\r
69 absolutize the filename: it will (wrongly) turn the default value `notmuch'
\r
70 into `$CWD/notmuch'.
\r
72 Signed-off-by: Thomas Schwinge <thomas@schwinge.name>
\r
78 As stated above, if someone has (more Emacs knowledge and) a better
\r
79 solution, please shout.
\r
81 An additional item to conider: this solves the issue with tilde
\r
82 expansion, but what about other shell magic like filename expansion
\r
83 (globbing; which is what shell-quote-wildcard-pattern explicitly does
\r
84 *not* quote / escape)?
\r
87 Once we have determined what we actually want, is it OK to send a
\r
88 testsuite patch to make it use such a ``nonstandard'' path, for catching
\r
89 regressions early in the future?
\r
95 emacs/notmuch-lib.el | 4 ++--
\r
96 emacs/notmuch-show.el | 4 ++--
\r
97 2 files changed, 4 insertions(+), 4 deletions(-)
\r
99 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
100 index dd180ee..fdeb32b 100644
\r
101 --- a/emacs/notmuch-lib.el
\r
102 +++ b/emacs/notmuch-lib.el
\r
103 @@ -61,7 +61,7 @@ the user hasn't set this variable with the old or new value."
\r
105 ;; Trim off the trailing newline.
\r
106 (substring (shell-command-to-string
\r
107 - (concat notmuch-command " --version"))
\r
108 + (concat (shell-quote-wildcard-pattern notmuch-command) " --version"))
\r
110 (if (string-match "^notmuch\\( version\\)? \\(.*\\)$"
\r
112 @@ -72,7 +72,7 @@ the user hasn't set this variable with the old or new value."
\r
113 "Return a value from the notmuch configuration."
\r
114 ;; Trim off the trailing newline
\r
115 (substring (shell-command-to-string
\r
116 - (concat notmuch-command " config get " item))
\r
117 + (concat (shell-quote-wildcard-pattern notmuch-command) " config get " item))
\r
120 (defun notmuch-database-path ()
\r
121 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
122 index 3a60d43..820f90f 100644
\r
123 --- a/emacs/notmuch-show.el
\r
124 +++ b/emacs/notmuch-show.el
\r
125 @@ -957,12 +957,12 @@ than only the current message."
\r
126 (let (shell-command)
\r
128 (setq shell-command
\r
129 - (concat notmuch-command " show --format=mbox "
\r
130 + (concat (shell-quote-wildcard-pattern notmuch-command) " show --format=mbox "
\r
131 (shell-quote-argument
\r
132 (mapconcat 'identity (notmuch-show-get-message-ids-for-open-messages) " OR "))
\r
134 (setq shell-command
\r
135 - (concat notmuch-command " show --format=raw "
\r
136 + (concat (shell-quote-wildcard-pattern notmuch-command) " show --format=raw "
\r
137 (shell-quote-argument (notmuch-show-get-message-id)) " | " command)))
\r
138 (start-process-shell-command "notmuch-pipe-command" "*notmuch-pipe*" shell-command)))
\r
141 tg: (b3caef1..) t/emcs-quote_notmuch-command (depends on: master)
\r