This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem executing a .bat script in a directory with spaces using bash

On Fri, 3 Sep 2004, Christopher Cobb wrote:

> I get different results than you do.  It seems to work as expected:
> chcobb@CHCOBB-054009 /c/Documents and Settings 09:45:46
> 511$ cat test.bat
> echo %1
> chcobb@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/ (warning: a 590!-line function).
      |\      _,,,---,,_
ZZZzz /,`.-'`'    -.  ;-;;,_
     |,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:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]