Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com From: Christopher Cobb Subject: Re: Problem executing a .bat script in a directory with spaces using bash Date: Tue, 7 Sep 2004 15:20:03 +0000 (UTC) Lines: 54 Message-ID: References: <5c8adab704090207557a3a359a AT mail DOT gmail DOT com> <4137566C DOT 7070203 AT sbcglobal DOT net> <5c8adab704090210405ea696e4 AT mail DOT gmail DOT com> <413760BD DOT 2080504 AT sbcglobal DOT net> <5c8adab70409021123291886c7 AT mail DOT gmail DOT com> <41376CD2 DOT 9090102 AT comcast DOT net> <41376D75 DOT 1060806 AT comcast DOT net> <4139AF96 DOT 4274702 AT dessent DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet AT sea DOT gmane DOT org X-Gmane-NNTP-Posting-Host: main.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 162.70.244.40 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.8) X-IsSubscribed: yes Christopher Cobb email.com> writes: > > Brian Dessent dessent.net> writes: > > > > Interesting function. However, I found that it chokes if the name of > > the command to run has spaces, even if they are properly quoted on the > > command line, e.g. > > > > That's interesting. I'm running Win XP and even with your patches I /still/ > get an error when a batch file path with spaces is given. > What I see is that this problem exists even from a cmd.exe window: This works as expected: C:\>type "C:\Documents and Settings\test.bat" echo %1 C:\>"C:\Documents and Settings\test.bat" "Hello, world." "Hello, world." However, this does not work: C:\>cmd /c "C:\Documents and Settings\test.bat" "Hello, world." 'C:\Documents' is not recognized as an internal or external command, operable program or batch file. The problem seems to be the /two/ sets of quotes. Removing the quotes around "Hello, world." results in: C:\>cmd /c "C:\Documents and Settings\test.bat" Hello, world. C:\>echo Hello Hello This gets us to the batch file, but it loses the second argument. Just for the record, this is the same (but undesired) behavior invoking the batch file directly but without quotes on the arguments: C:\>"C:\Documents and Settings\test.bat" Hello, world. C:\>echo Hello Hello Conclusion: cmd.exe command line processing is brain dead. Among the problems are that cmd.exe looks for /exactly/ one pair of quotes and no more (see my previous message). And that (double) quotes are the /only/ way of quoting spaces. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/