This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Problem passing Windows path names from batch file to bash script
- From: Gary Johnson <garyjohn at spk dot agilent dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 27 Oct 2006 20:43:48 -0700
- Subject: Problem passing Windows path names from batch file to bash script
I am trying to pass Windows path names from a Windows batch file to
a Cygwin bash script. I have found a solution using Windows
environment variable substitution to replace \s with /s before
passing the name to bash, but I cannot figure out how to pass the
name without that replacement. The problem is with names of the
form
"\\host\user\file with spaces"
No matter what I've tried, bash insists on collapsing the two
leading \s to one, like this,
\host\user\file with spaces
before anything else can be done with the name.
Here's an illustration of the problem. I've created a batch file,
foo.bat, that contains the following lines:
@echo off
echo %1 '%1'
C:\cygwin\bin\bash -c 'echo %1'
C:\cygwin\bin\bash bar %1 '%1'
and a file, bar, in the same directory containing these lines:
echo $1 "$1"
echo $2 "$2"
Executing the following command from the Command Prompt,
foo "\\host\user\file with spaces"
produces the following output:
"\\host\user\file with spaces" '"\\host\user\file with spaces"'
\host\user\file with spaces
\host\user\file with spaces \host\user\file with spaces
"\host\user\file with spaces" "\host\user\file with spaces"
I can come up with a number of reasons why I think the results
should be different, but that doesn't really matter, since there
must be something I'm missing. Would someone please explain this
behavior or direct me to the fine manual I should have read? How
should one pass such a path name from Windows to a bash script
without losing any information?
Thanks,
Gary
--
Gary Johnson | Agilent Technologies
garyjohn@spk.agilent.com | Wireless Division
| Spokane, Washington, USA
--
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/