问题
I am using mac os x
, and I have some trouble setting the $PATH
env. If the directory name is /path/to/add/a:b/bin
, how can I add this directory to $PATH
which is separated by :
?
回答1:
As far as I know, you can't. The obvious way to escape a :
character in $PATH
would be to use a backslash, but a quick experiment with Bash on Linux indicates that it doesn't work. OSX might behave differently, but I suspect you'd have the same problem.
Your best bet is to rename the directory. If it really needs to have that name, you can create a symbolic link and add that to your $PATH
:
$ cd /path/to/add
$ ln -s a:b a_b
$ PATH="$PATH:/path/to/add/a_b/bin"
来源:https://stackoverflow.com/questions/21641294/if-there-is-a-colon-in-the-directory-name-how-could-i-add-it-to-path