开发者

Pb with PATH declare as an environment variable

It is my first Post here so let me say Hello to the stackoverflow community before starting !

Here is my Problem :

  • i want to declare a PATH as an environment variable in Cygwin
  • then i want to be able to use this variable in any command
  • the difficulties comes when i have space character in the PATH

Here is what i try without sucess :

$ export MYPATH=/cygdrive/c/Program\ Files/Autodesk/Maya2011/
$ echo $MYPATH
$ /cygdrive/c/Program Files/Autodesk/Maya2011/
$ cd $MYPATH
$ bash: cd: /cydrive/c/Program: No such file or directory

i get excatly the same Error with all those various synthax

$ export MYPATH="/cygdrive/c/Program Files/Autodesk/Maya2011/"

idem with this one

$ export MYPATH=$MYPATH"/cygdrive/c/Program Files/Auto开发者_StackOverflow社区desk/Maya2011/"

I have no more ideas ... so if you guys can help me , it would be great !

Cheers

sk


You need to use quotes around $MYPATH the same as you would if you were use cd while typing out the path manually.

cd "$MYPATH"

is equivalent to

cd "/cygdrive/c/Program Files/Autodesk/Maya2011/"

Notice that the escape character '\' for the space is removed when you are setting $MYPATH so when $MYPATH is expanded for cd, the space is no longer escaped. Also note, cygwin doesn't like it if you try to escape the escape character too:

export MYPATH=/cygdrive/c/Program\\\ Files/Autodesk/Maya2011/

This will actually expand to

/cygdrive/c/Program\ Files/Autodesk/Maya2011/

but cygwin will yell at you for trying to use a MS-DOS style path.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜