开发者

Question about .profile generated by ubuntu 11.04

I noticed the following lines at the bottom of my ~/.profile that was generated from when I installed Ubuntu 11.04:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

I see the logic there, but shouldn't the PATH variable be exported?

# set PAT开发者_JAVA百科H so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    export PATH="$HOME/bin:$PATH"
fi

If not, then I don't understand how the value of PATH does not get lost once the bottom of the .profile file is reached, unless something is sourcing this file with . ~/.profile, which I do not see (at least explicitly) happening in any other shell script on the system.


If a variable is already exported, you don't have to export it again. And yes, the shell does (the moral equivalent of) source .profile when you start a login shell (unless you also have a .bash_profile; but then that should customarily source .profile in turn).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜