|
发表于 2008-11-12 22:00:30
|
显示全部楼层
多谢帮助。看了下文档,有一点不太明白,non-login shell不读取profile文件,但我在/etc/profile里的环境变量却是生效的(没有在其他的~/.bash_profile, /etc/bashrc, ~/.bashrc设置过)。
会不会是对root用户的,也就是/etc下的profile和rc文件都会读取? Post by knut;1835644
不知道我这样回答对不对,如果那里错了请大家指正。
虽然在X环境下开启的终端多数都是non-login shell 不读取 /etc/profile 或~/.bash_profile 但子程序还是会继承父程序的环境变量的。除非明确不继承。
在LFS 的4.4章节中有:
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
用完全空的环境来取代当前的环境(除了继承 HOME, TERM, PS1 变量外)
在X环境中,在打开终端之前,系统从哪个文件中来读取环境变量的设置的呢?X环境下肯定还是需要环境变量的,他是在哪个文件中设置的呢?
如果知道了X环境中环境变量来自哪个文件,那么在X环境下打开的终端肯定会继承那些已有的环境变量,在BLFS手册中有如下:An interactive non-login shell is also started with a terminal program such as xterm or konsole from within a graphical environment. This type of shell invocation normally copies the parent environment and then reads the user's ~/.bashrc file for additional startup configuration instructions. |
|