[vox-tech] how to handle spaces in a directory path

Peter Jay Salzman p at dirac.org
Wed Oct 14 10:40:38 PDT 2009


On Wed 14 Oct 09, 12:45 PM, Hai Yi <yihai2004 at gmail.com> said:
> Hi, i know this is a simple one but it's also a haunting ghost. :-)
> 
> This is what I set in my .bashrc:
> 
> export VIM_HOME='/cygdrive/c/Program\ Files/Vim/vim72'
> export VC_HOME='/cygdrive/c/"Program Files"/"Microsoft Visual Studio 9.0"/VC'
> 
> 
> and This is what I tested from cygwin console:
> 
> $ echo $VIM_HOME
> /cygdrive/c/Program\ Files/Vim/vim72
> 
> hai at zodiac-1 ~
> $ cd $VIM_HOME
> bash: cd: /cygdrive/c/Program\: No such file or directory
> 
> hai at zodiac-1 ~
> $ echo $VC_HOME
> /cygdrive/c/"Program Files"/"Microsoft Visual Studio 9.0"/VC
> 
> hai at zodiac-1 ~
> $ cd $VC_HOME
> bash: cd: /cygdrive/c/"Program: No such file or directory
> 
> Anyone can tell me what is the proper way to handle spaces in a
> directory path? In a cygwin environment?
> 
> Thanks !
> 
> Hai


Hai, you need to quote the variable, as in:

   ls "$VC_HOME"

I use cygwin extensively at work, and for this reason, I always install
stuff into "D:\bin" instead of "D:\Program Files".  You can function with
spaces in directory names; it just makes things more inconvenient.

Pete


More information about the vox-tech mailing list