Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 219C242D2A5 for ; Tue, 11 Jan 2011 10:09:35 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "To" X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2jbd8COwdmJx for ; Tue, 11 Jan 2011 10:09:31 -0800 (PST) Received: from smtprelay02.ispgateway.de (smtprelay02.ispgateway.de [80.67.31.40]) by olra.theworths.org (Postfix) with ESMTP id CABE842D28A for ; Tue, 11 Jan 2011 10:09:30 -0800 (PST) Received: from [87.180.67.225] (helo=stokes.schwinge.homeip.net) by smtprelay02.ispgateway.de with esmtpa (Exim 4.68) (envelope-from ) id 1Pciev-0002Km-LR for notmuch@notmuchmail.org; Tue, 11 Jan 2011 19:09:29 +0100 Received: (qmail 21438 invoked from network); 11 Jan 2011 18:09:07 -0000 Received: from unknown (192.168.111.252) by stokes.schwinge.homeip.net with QMQP; 11 Jan 2011 18:09:07 -0000 Received: (nullmailer pid 19463 invoked by uid 1000); Tue, 11 Jan 2011 12:02:14 -0000 From: Thomas Schwinge To: notmuch@notmuchmail.org Subject: [PATCH] Properly quote Emacs' notmuch-command. Date: Tue, 11 Jan 2011 13:02:07 +0100 Message-Id: <1294747327-19430-1-git-send-email-thomas@schwinge.name> X-Mailer: git-send-email 1.7.1 To: notmuch@notmuchmail.org X-Df-Sender: thomas@schwinge.name Cc: Thomas Schwinge X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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: Tue, 11 Jan 2011 18:09:35 -0000 From: Thomas Schwinge 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 --- 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)