delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/07/11:20:25

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 <ccobb AT email DOT com>
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: <loom.20040907T170440-285@post.gmane.org>
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> <loom DOT 20040903T154613-572 AT post DOT gmane DOT org> <Pine DOT GSO DOT 4 DOT 61 DOT 0409030951520 DOT 28876 AT slinky DOT cs DOT nyu DOT edu> <loom DOT 20040903T163722-711 AT post DOT gmane DOT org> <4139AF96 DOT 4274702 AT dessent DOT net> <loom DOT 20040907T163147-558 AT post DOT gmane DOT org>
Mime-Version: 1.0
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 <ccobb <at> email.com> writes:

> 
> Brian Dessent <brian <at> 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019