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#8541: start-process fails when both the program path and an argument contain spaces Date: Sun, 24 Apr 2011 22:41:53 +0300 Message-ID: <83zknfa132.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1303675674 9681 80.91.229.12 (24 Apr 2011 20:07:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 24 Apr 2011 20:07:54 +0000 (UTC) Cc: 8541@debbugs.gnu.org To: Ivar Rummelhoff Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 24 22:07:47 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QE5as-0002WA-R4 for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Apr 2011 22:07:46 +0200 Original-Received: from localhost ([::1]:55298 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QE5as-0001jq-6i for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Apr 2011 16:07:46 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:57590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QE5an-0001cG-Sa for bug-gnu-emacs@gnu.org; Sun, 24 Apr 2011 16:07:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QE5am-0007u4-Tn for bug-gnu-emacs@gnu.org; Sun, 24 Apr 2011 16:07:41 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59708) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QE5am-0007u0-SE for bug-gnu-emacs@gnu.org; Sun, 24 Apr 2011 16:07:40 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QE5Cw-0004L3-EF; Sun, 24 Apr 2011 15:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Apr 2011 19:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8541 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8541-submit@debbugs.gnu.org id=B8541.130367414316631 (code B ref 8541); Sun, 24 Apr 2011 19:43:02 +0000 Original-Received: (at 8541) by debbugs.gnu.org; 24 Apr 2011 19:42:23 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QE5CJ-0004KB-54 for submit@debbugs.gnu.org; Sun, 24 Apr 2011 15:42:23 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QE5CF-0004Jy-PM for 8541@debbugs.gnu.org; Sun, 24 Apr 2011 15:42:20 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0LK60020096BGQ00@a-mtaout20.012.net.il> for 8541@debbugs.gnu.org; Sun, 24 Apr 2011 22:41:51 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([77.127.55.52]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LK6001O39DPVO70@a-mtaout20.012.net.il>; Sun, 24 Apr 2011 22:41:51 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 24 Apr 2011 15:43:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:45970 Archived-At: > Date: Sun, 24 Apr 2011 12:01:17 +0200 > From: Ivar Rummelhoff > > 1. Trying to execute > > (start-process "name" "buffer" "D:\\tmp\\xxx yyy\\foo.bat" "yada yada") > > writes the following to "buffer": > > 'd:\tmp\xxx' is not recognized as an internal or external command, > operable program or batch file. > > Process name exited abnormally with code 1 > > Emacs version: GNU Emacs 23.3.1 (i386-mingw-nt6.1.7601) of 2011-03-10 on 3249CTO > > > 2. If space is avoided in either the program path or the argument, as in > > (start-process "name" "buffer" "D:\\tmp\\foo.bat" "yada yada") > or > (start-process "name" "buffer" "D:\\tmp\\xxx yyy\\foo.bat" "yada-yada") > > then everything works well. > > > 3. The same problem occurs when I give `start-process' the program > name only (instead of the full path) as long as the full path to the > program contains spaces (and one of the arguments contains spaces). > > > 4. Quoting the program path or the argument (with " or \) does not > help. If quote the program path, I get "no such file or directory"; > and quoting the argument has no effect as long as there is still a > space character "in there". (Besides, it seems any quoting of the > arguments is passed on to the program.) This is due to deficiencies in the Windows API for launching programs (CreateProcess): it concatenates the command arguments into a single string, separated by blanks.. To work around, invoke the command through cmd.exe, and use cmd.exe-specific quoting character '^'. Like this: (start-process "name" "buffer" "cmd.exe" "/c" "D:\\tmp\\xxx^ yyy\\foo.bat yada^ yada") This is fragile, and you will need to redo the quoting if you invoke other programs or have whitespace in other places. But I don't know how to do better, given the Windows API misfeatures. It is best to avoid whitespace in the arguments. For file names, you can use 8+3 aliases, if you cannot control the names of the files or directories.