问题
Trying to customize the $PATH
env variable on OSX with the following in .profile
:
PATH=(
$HOME/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin/
/sbin
)
PATH=$(IFS=:; echo "${PATH[*]}")
export PATH
When this is loaded, I verified the path by doing echo $PATH
and the output looks correct:
echo $PATH
/Users/apple/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
However, it doesn't look like any of the above path works.
ls
- bash: (something like not able to find command ls, which is in /usr/bin)
What am I missing here?
回答1:
Change PATH
array variable name to something different, like:
P=(
$HOME/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin/
/sbin
)
PATH=$(IFS=:; echo "${P[*]}")
export PATH
I'm not sure why, though. If I figure that out, I'll update this answer.
Update: for a little bit more info on this, see this topic.
来源:https://stackoverflow.com/questions/18568933/joining-array-into-path-in-bash-on-osx