Alex Rivera | Logout

Cygwin: using a path variable containing a windows path (with a space in it)

Asked 2010-12-02T11:29:24.697
33

I want to add some dirs to my PATH. Unfortunately these dirs are located in windows path containing space (like the Documents and Settings)

I've unsuccessfully tried to:

Create a variable:

43598811@E250BZD20015026 ~
$ winhome="/cygdrive/c/Documents\ and\ Settings/43598811/"

43598811@E250BZD20015026 ~
$ cd $winhome
bash: cd: /cygdrive/c/Documents\: No such file or directory    

43598811@E250BZD20015026 ~
$ cd "$winhome"
bash: cd: /cygdrive/c/Documents\ and\ Settings/43598811/: No such file or directory

Create an alias:

43598811@E250BZD20015026 ~
$ alias winhome="/cygdrive/c/Documents\ and\ Settings/43598811/"

43598811@E250BZD20015026 ~
$ winhome
bash: /cygdrive/c/Documents and Settings/43598811/: is a directory

43598811@E250BZD20015026 ~
$ cd winhome
bash: cd: winhome: No such file or directory

Use a soft link: it is working... but I don't want to use this

Any suggestion ?

Edit
Report

2 Answers

2

I am a complete cwywin noob - but surely creating a symlink back to your windows home has to be an easy first step?

ie:

 wh="/cygdrive/c/Documents and Settings/Erich/My Documents"
 ln -s "$wh" wh

then you can just:

 ls wh

you could do the same thing for your desktop etc... and worry no more about the win/cyg conversion?

edit now I've used cygpath - I beleive this is the tool to use - with or without symlinks it is a neat little package for dealing with the *nix/wind path disjoint

answered 2012-01-31T12:06:47.193
1

The approach with the variable should work if you defined it correctly. Yours contains backslashes for no good reason.

answered 2010-12-02T11:34:44.970

Your Answer