delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/03/10:06:22

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
Date: Fri, 3 Sep 2004 10:06:06 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Christopher Cobb <ccobb AT email DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: Problem executing a .bat script in a directory with spaces using bash
In-Reply-To: <loom.20040903T154613-572@post.gmane.org>
Message-ID: <Pine.GSO.4.61.0409030951520.28876@slinky.cs.nyu.edu>
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>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.39

On Fri, 3 Sep 2004, Christopher Cobb wrote:

> I get different results than you do.  It seems to work as expected:
>
> chcobb AT CHCOBB-054009 /c/Documents and Settings 09:45:46
> 511$ cat test.bat
> echo %1
>
> chcobb AT CHCOBB-054009 /c/Documents and Settings 09:45:48
> 511$ ./test.bat
>
> C:\Documents and Settings>echo
> ECHO is on.

I believe you're missing the point.  Try

./test.bat "hello world"

and you'll get the error.

I've come across this when writing a pure Windows loader for another
program.  The above is actually an idiosyncrasy of the way spawn() works
in Cygwin (and, incidentally, in Windows' own MSVCRT) -- it calls
CreateProcess, which expects all arguments combined into one command
string (which, in turn, is later parsed for separate arguments - yes,
retarded, I know).  The fact is that, if any argument contains spaces, it
has to be quoted before CreateProcess() is invoked.  Cygwin apparently
doesn't do this properly to the first argument, so the above breaks.  See
spawn_guts() in winsup/cygwin/spawn.cc (warning: a 590!-line function).
<http://cygwin.com/acronyms/#PTC>.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw

--
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