From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#20744: shell-quote-argument in Emacs 24.5 and Emacs 25 on Windows cannot figure out path correctly Date: Fri, 05 Jun 2015 23:13:18 +0300 Message-ID: <83oaktoqw1.fsf@gnu.org> References: <5571CF77.5000902@gmail.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1433535267 5725 80.91.229.3 (5 Jun 2015 20:14:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Jun 2015 20:14:27 +0000 (UTC) Cc: 20744@debbugs.gnu.org To: Da Zhang Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jun 05 22:14:12 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z0y0K-0004EH-0g for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Jun 2015 22:14:12 +0200 Original-Received: from localhost ([::1]:49442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0y0J-0001Ih-9Y for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Jun 2015 16:14:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0y0G-0001IR-4B for bug-gnu-emacs@gnu.org; Fri, 05 Jun 2015 16:14:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0y0B-00051Q-4C for bug-gnu-emacs@gnu.org; Fri, 05 Jun 2015 16:14:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0y0B-00051K-05 for bug-gnu-emacs@gnu.org; Fri, 05 Jun 2015 16:14:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Z0y0A-00063k-La for bug-gnu-emacs@gnu.org; Fri, 05 Jun 2015 16:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Jun 2015 20:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20744 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.143353521923252 (code B ref -1); Fri, 05 Jun 2015 20:14:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Jun 2015 20:13:39 +0000 Original-Received: from localhost ([127.0.0.1]:42183 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z0xzm-00062x-CV for submit@debbugs.gnu.org; Fri, 05 Jun 2015 16:13:38 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45664) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z0xzj-00062g-JY for submit@debbugs.gnu.org; Fri, 05 Jun 2015 16:13:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0xzd-0004un-6e for submit@debbugs.gnu.org; Fri, 05 Jun 2015 16:13:30 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:39787) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0xzd-0004uh-3T for submit@debbugs.gnu.org; Fri, 05 Jun 2015 16:13:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0xzb-0001G1-Sm for bug-gnu-emacs@gnu.org; Fri, 05 Jun 2015 16:13:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0xzW-0004rn-Se for bug-gnu-emacs@gnu.org; Fri, 05 Jun 2015 16:13:27 -0400 Original-Received: from mtaout25.012.net.il ([80.179.55.181]:54528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0xzW-0004ql-Fa for bug-gnu-emacs@gnu.org; Fri, 05 Jun 2015 16:13:22 -0400 Original-Received: from conversion-daemon.mtaout25.012.net.il by mtaout25.012.net.il (HyperSendmail v2007.08) id <0NPH00H00MGZ6G00@mtaout25.012.net.il> for bug-gnu-emacs@gnu.org; Fri, 05 Jun 2015 23:09:14 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout25.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NPH00BCWMND7S80@mtaout25.012.net.il>; Fri, 05 Jun 2015 23:09:14 +0300 (IDT) In-reply-to: <5571CF77.5000902@gmail.com> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:103630 Archived-At: > Date: Fri, 05 Jun 2015 12:33:59 -0400 > From: Da Zhang > > I use python mode (python.el) for some python programming. When I invoke > the command python-shell-send-buffer, my Emacs always reports "Searching > for program: no such file or directory, > c\:/Anaconda3/Scripts/ipython.exe". > > I traced down the cause of this problem, and found the following lines > in python.el: > (defun python-shell-parse-command () ;FIXME: why name it "parse"? > "Calculate the string used to execute the inferior Python process." > ;; FIXME: process-environment doesn't seem to be used anywhere within > ;; this let. > (let ((process-environment (python-shell-calculate-process-environment)) > (exec-path (python-shell-calculate-exec-path))) > (format "%s %s" > ;; FIXME: Why executable-find? > (shell-quote-argument (executable-find python-shell-interpreter)) > python-shell-interpreter-args))) > > The function call > (shell-quote-argument (executable-find python-shell-interpreter)) > changed the path of my python interpreter from > "c:/Anaconda3/Scripts/ipython.exe" > to > "c\\:/Anaconda3/Scripts/ipython.exe". > > I worked around this problem by replacing the function call > (shell-quote-argument (executable-find python-shell-interpreter)) > with > (executable-find python-shell-interpreter) ;; edited by DZ on > 2015/06/05: (shell-quote-argument) caused the problem of > "c\\:/Anaconda3/Scripts/ipython.exe" > > To further analyze the problem, I found the function > shell-quote-argument defined in subr.el does not deal with the case when > bash from cygwin is used. For the record, this is bug #20237. > I added the following lines in the cond statement, to solve the problem. > ((and (eq system-type 'windows-nt) (if (string-match ".*cygwin.*" > (w32-shell-name)) t nil)) ;; DZ's edit on 6/5/2015 > (if (equal argument "") > "''" > ;; Quote everything except POSIX filename characters. > ;; This should be safe enough even for really weird shells. > (replace-regexp-in-string > "\n" "'\n'" > (replace-regexp-in-string "[^-0-9a-zA-Z_./\n:]" "\\\\\\&" argument)))) I'm sorry, but I don't see how we can accept such a change: it means that when the Cygwin Bash is used as the shell, the ':' character will not be quoted, which I think could cause trouble in some cases. Maybe some Bash expert could chime in and tell whether problems are possible with Bash in this case. Is there any way you could avoid using the Cygwin Bash as the shell when running the native Windows build of Emacs? That would make the problem go away without any need for changes.