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: Spaces in Paths


On Mon, 28 Mar 2005 12:50:12 -0800,  wrote:

>zzapper wrote:
>
>>Hi,
>>Mysql has now moved under c:/program files/
>>My backup bash script will run correctly if I use the follwing syntax 
>>/cygdrive/c/program\ files/mysql/MySQL\ Server\ 4.1/bin/mysqldump.exe $params
>>However it doesn't work if I try to load the above into a variable
>>eg
>>mysqldump='/cygdrive/c/program\ files/mysql/MySQL\ Server\ 4.1/bin/mysqldump.exe'
>>I get "/cygdrive/c/program\: No such file or directory..."
>>Is this just hard luck?
>>
>----
>    Basically you need to put double quotes around the $mysqldump
>usage: "$mysqldump".
>
>Here's an example function to detect argument parsing:
>function sa () {
>    if (($#==0)); then return; fi
>    echo \"$1\"
>    shift
>    sub $*
>}
>--- first the args as they look when you manually type in the
>backslashes -- note that the backslashes are removed.
>/> sa /program\ files/mysql/MySQL\ Server\ 4.1/bin/mysqldump.exe
>"/program files/mysql/MySQL Server 4.1/bin/mysqldump.exe"
>Another way of getting same thing:
>/> sa "/program files/mysql/MySQL Server 4.1/bin/mysqldump.exe"
>"/program files/mysql/MySQL Server 4.1/bin/mysqldump.exe"
>
>But if you assign to a variable, it loses the quotes when expanded:
>
>/> foo="/program files/mysql/MySQL Server 4.1/bin/mysqldump.exe"
>/> sa $foo
>"/program"
>"files/mysql/MySQL"
>"Server"
>"4.1/bin/mysqldump.exe"
>
>What you want is to put quotes around the variable name:
>
>/> sa "$foo"
>"/program files/mysql/MySQL Server 4.1/bin/mysqldump.exe"
>
>It's a minor "gotcha" catching those of us who were raised w/o
>spaces in file names that has bitten me more than once, as well.
>
>It should be a habit on linux, as well,as spaces can occur
>there as well.
>
Linda
I don't know why I haven't had this problem before, except I usually try to avoid installing into
c:\program files\  or I cheat by copying the executable into a short path. 

Dare I timidly suggest that this should be in the Cygwin FAQ section "spaces in file names/paths"





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