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 :
?
Asked
Active
Viewed 4,185 times
7

Keith Thompson
- 254,901
- 44
- 429
- 631

eccstartup
- 501
- 8
- 24
-
From the [POSIX specification](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html): "Since
is a separator in this context, directory names that might be used in PATH should not include a – chepner Feb 08 '14 at 19:01character."
1 Answers
7
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"

Keith Thompson
- 254,901
- 44
- 429
- 631