From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#19350: #19350 24.4; Incorrect quoting of %-signs for Windows command shell Date: Wed, 10 Aug 2016 09:00:36 -0400 Message-ID: References: <877fxyt4bd.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1470844703 10799 195.159.176.226 (10 Aug 2016 15:58:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 10 Aug 2016 15:58:23 +0000 (UTC) To: Demetrios Obenour , 19350@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Aug 10 17:58:19 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bXVtZ-0002dY-KV for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Aug 2016 17:58:17 +0200 Original-Received: from localhost ([::1]:42423 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXVtW-0003wW-FC for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Aug 2016 11:58:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXVtO-0003oJ-Lr for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2016 11:58:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXVtK-0007is-I7 for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2016 11:58:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54761) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXVtK-0007im-DR for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2016 11:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bXVtK-00039O-7M for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2016 11:58:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <877fxyt4bd.fsf@gmail.com> Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Aug 2016 15:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19350 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 19350-submit@debbugs.gnu.org id=B19350.147084465712074 (code B ref 19350); Wed, 10 Aug 2016 15:58:02 +0000 Original-Received: (at 19350) by debbugs.gnu.org; 10 Aug 2016 15:57:37 +0000 Original-Received: from localhost ([127.0.0.1]:52473 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bXVsu-00038g-SU for submit@debbugs.gnu.org; Wed, 10 Aug 2016 11:57:37 -0400 Original-Received: from mail-oi0-f46.google.com ([209.85.218.46]:33962) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bXVst-00038T-As for 19350@debbugs.gnu.org; Wed, 10 Aug 2016 11:57:35 -0400 Original-Received: by mail-oi0-f46.google.com with SMTP id l203so65040556oib.1 for <19350@debbugs.gnu.org>; Wed, 10 Aug 2016 08:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to; bh=USTde2zfpEG3KcHl4f3CSzriKy35VKCqkX/qaROxXCw=; b=X5WyICQN9eJOPPtTY5afZamt7a8JevR9RgX9awh3hjOjn90VUDzMvTeDHwQYqY5sd4 dulfWpKH+UvhdASn1LnBSj1Pj4Q0PDO/yk83UkECrw15vupGZJXqVfsFaB5PaSDwMxkQ Y6Wy6QIr7/j0LyZxDQVgVd+r034abtAk7B2Jc68yD+WLrlCV7SHz3CrQpSst1VOxrEaF QNVAAF2DWgzjsrmmBUAXfKc1hhaHJfE6zDrQMUxI34i6NyeaiR6LI2YRXaJOuPaYczQ9 9wz79nlelxYNIaIVFPGImu8vvgZ99QBXxTiGmO5xCfNXKTiUGVAEGCizpvIrIFcArd/9 jKGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=USTde2zfpEG3KcHl4f3CSzriKy35VKCqkX/qaROxXCw=; b=iYW14fvWiwgBBxsiuWwTT3xj08X4SqbSkTecdvtCmQN/XAwNBuNqhY8rsaO6dZjmxm CHdx7c4HZ9j6qq6jNESa2C/Df7tQqZO6lRx6Tumip2uM4TqxacK0FpARosh15feqUd6E KunCYpMa8L0HQPC1+CdFjbA3vN+53FzrNnZsyVMRBiZ2TPTWj/NG8pWLJZp11tQSpony 5yKZJqyeEbE4TAoYASaYRYXaH+jDL/PDLd9+JnPwrG404qO4LGLobMZq5m9gAoQO1tgt x/6uMj+fJ/d+8JGfS3kA11PYVwkYrHZCBiIyNnu/B3aeggkUbBlFzFd/NMra8zP4s7ru PpaQ== X-Gm-Message-State: AEkoouvMGVoVdvWLeWFBungimpHmblaADP5a2CQXoew0B8Ra+fFk4i6MyC4bk5nJjSh7jCD2YFLzk5X17o8w9A== X-Received: by 10.202.73.205 with SMTP id w196mr1933007oia.40.1470834036887; Wed, 10 Aug 2016 06:00:36 -0700 (PDT) Original-Received: by 10.157.7.161 with HTTP; Wed, 10 Aug 2016 06:00:36 -0700 (PDT) X-Google-Sender-Auth: p-tnlB2cEX9P1ctnKLWLHZLMmmo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:122034 Archived-At: tag 19350 confirmed severity 19350 minor quit > Looking at the code in subr.el, it is clear that Emacs mishandles > %-signs when escaping for the Windows command interpreter. [...] > > I deleted the lossage from the report, as there is no point in including > it, this being a logic error in subr.el. In fact, the buggy code is dead > on my machine (I run Linux) -- I happened to know about the problem on > Windows. Well, it would have been nice to mention which function you're talking about, and give an example problematic string. I guess it's shell-quote-argument: Evaluating (let ((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 "with-caret" %ca% On the other hand, this is such an obscure corner case, I'm don't know if it's even worth fixing. > A method of handling % that I believe to be fully > robust is to follow (not precede) each series of % characters with > %CD:~,0%. This is an expansion that always expands to the empty > string. It will work provided that: > > * Command Extensions are enabled. I'm not sure if Emacs can assume this. > > * It is not possible for cmd.exe to interpret an environment variable > whose name is the empty string. I found that adding "=emptyvar" to process-environment caused "Spawning child process: exec format error", so I guess this assumption is safe.