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]

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


I'm currently using cygwin 1.5.10 and I'm having a problem trying to
run a .bat file in
a directory with spaces.  Here's an example of what I'm doing.

1) mkdir C:\Space Dir
2) Create a file called test.bat in C:\Space Dir
3) Just add a single line with "echo %1" in test.bat
4) Start cygwin
$ cd C:/Space\ Dir
$ ./test.bat hello

c:\Space Dir>echo hello
hello

$ ./test.bat "hello world"
'c:\Space' is not recognized as an internal or external command,
operable program or batch file.

$

If I try to run test.bat with an argument with spaces it fails with
the error above.
If I move test.bat to a directory without spaces, it works correctly.

I know that cmd has some weird behavior when you execute a quoted cmd.
Just using cmd in certain ways (outside of cygwin) will reproduce the
issue mentioned
above.

Do the following:
C:\>cmd /c "C:\Space Dir\test.bat" hello

C:\>echo hello
hello

C:\>cmd /c "C:\Space Dir\test.bat" "hello world"
'C:\Space' is not recognized as an internal or external command,
operable program or batch file.

One way to actually get the second command to work is to quote the
entire command
like this:

C:\>cmd /c ""C:\Space Dir\test.bat" "hello world""
C:\>echo "hello world"
"hello world"

Unfortunately we have some batch scripts which live in directories
with spaces that I'd
really like to run.

Thanks.

Sean

Attachment: cygcheck.out
Description: Binary data

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

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