GNU bug report logs - #8541
start-process fails when both the program path and an argument contain spaces

Previous Next

Package: emacs;

Reported by: Ivar Rummelhoff <ivarru <at> gmail.com>

Date: Sun, 24 Apr 2011 10:25:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8541 in the body.
You can then email your comments to 8541 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8541; Package emacs. (Sun, 24 Apr 2011 10:25:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ivar Rummelhoff <ivarru <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 24 Apr 2011 10:25:03 GMT) Full text and rfc822 format available.

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

From: Ivar Rummelhoff <ivarru <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: start-process fails when both the program path and an argument
	contain spaces
Date: Sun, 24 Apr 2011 12:01:17 +0200
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.)


5. There seems to be no work-around for this in emacs lisp.


Best Regards,

Ivar Rummelhoff




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8541; Package emacs. (Sun, 24 Apr 2011 19:43:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ivar Rummelhoff <ivarru <at> gmail.com>
Cc: 8541 <at> debbugs.gnu.org
Subject: Re: bug#8541: start-process fails when both the program path and
	an	argument contain spaces
Date: Sun, 24 Apr 2011 22:41:53 +0300
> Date: Sun, 24 Apr 2011 12:01:17 +0200
> From: Ivar Rummelhoff <ivarru <at> gmail.com>
> 
> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8541; Package emacs. (Wed, 30 Sep 2015 16:30:04 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: 8541 <at> debbugs.gnu.org
Subject: Re: bug#8541: start-process fails when both the program path and an
 argument contain spaces
Date: Wed, 30 Sep 2015 12:29:41 -0400
I believe this was fixed along with #18745 (while searching for it I
happened to stumble upon this one).

A nicer workaround suggested by Eli on that bug is to use w32-short-file-name:

    (start-process "name" "buffer"
                   (w32-short-file-name "D:\\tmp\\xxx yyy\\foo.bat")
                   "yada yada")




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Thu, 01 Oct 2015 07:56:01 GMT) Full text and rfc822 format available.

Notification sent to Ivar Rummelhoff <ivarru <at> gmail.com>:
bug acknowledged by developer. (Thu, 01 Oct 2015 07:56:02 GMT) Full text and rfc822 format available.

Message #16 received at 8541-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Noam Postavsky <npostavs <at> users.sourceforge.net>
Cc: 8541-done <at> debbugs.gnu.org
Subject: Re: bug#8541: start-process fails when both the program path and
 an	argument contain spaces
Date: Thu, 01 Oct 2015 10:53:56 +0300
> Date: Wed, 30 Sep 2015 12:29:41 -0400
> From: Noam Postavsky <npostavs <at> users.sourceforge.net>
> 
> I believe this was fixed along with #18745 (while searching for it I
> happened to stumble upon this one).

Indeed, so closing this one.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 29 Oct 2015 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 238 days ago.

Previous Next


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