GNU bug report logs - #19350
24.4; Incorrect quoting of %-signs for Windows command shell

Previous Next

Package: emacs;

Reported by: Demetrios Obenour <demetriobenour <at> gmail.com>

Date: Thu, 11 Dec 2014 18:45:02 UTC

Severity: minor

Tags: confirmed, wontfix

Found in version 24.4

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

Full log


Message #50 received at 19350 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 19350 <at> debbugs.gnu.org, Demi Obenour <demiobenour <at> gmail.com>
Subject: Re: bug#19350: #19350 24.4; Incorrect quoting of %-signs for Windows
 command shell
Date: Mon, 3 Oct 2016 14:47:37 -0400
[Message part 1 (text/plain, inline)]
On Mon, Aug 15, 2016 at 11:01 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> From my POV, as long as Emacs itself doesn't produce such shell
> commands and/or environment variables for any of its features,
> avoiding this becomes user's responsibility, just like when working at
> the shell prompt.  Of course, if we can find a reliable solution to
> the problem that doesn't take away features, that'd be better,

So I have been thinking about this. As far as I can tell, the %CD:~,0%
hack is the only way to solve it. We can make it conditional on having
command extensions enabled, see attached.

The probing command I used for the default value for
w32-shell-command-extensions causes an error while dumping ("Searching
for program: No such file or directory,
C:/Users/npostavs/src/emacs/emacs-25/nt/cmdproxy.exe") so I've
commented it out for now. With this patch,

(let ((w32-shell-command-extensions t)
      (process-environment (cl-list* "ca^=with-caret"
                                     "ca=without-caret"
                                     process-environment)))
  (insert (shell-command-to-string
           (format "echo %s %s %s"
                   "%ca%"
                   (shell-quote-argument "%ca%")
                   "%%CD:~,0%ca%%CD:~,0%"))))

gives

without-caret "%ca%" %ca%

If this approach makes sense I can fix up the patch.
[escaping-percent.diff (text/plain, attachment)]

This bug report was last modified 7 years and 101 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.