|
发表于 2008-10-22 15:05:59
|
显示全部楼层
不好意思,怎么帮助新人的贴变成吵架了?
为了确定BLFS的代码是否正确,我刚才专门确认了一下。结果,BLFS的代码是正确的!
我实验的方法如下:
首先,到BLFS 6.3 手册的第3章:The Bash Shell Startup Files
它会给出配置/etc/profile的代码。
然后,我打开了终端,第一行代码输入了:
cat>>temp<<"EOF"
我用temp文件代替/etc/profile
接着,我用鼠标复制了下面所有的代码,一直到EOF
然后粘贴到终端。
最后两行显示将是:
> # End /etc/profile
> EOF
然后我回车确认。当前目录下生成了temp文件。
然后我less了temp文件
less temp
和BLFS手册上的代码认真对照。结果是完全一样的。所有的代码,包括$号和{}号,都准确地输入了temp文件。
下面是输出结果。
因为我在BLFS过程中,根本没有进行第三章,因此并没有认真去校验过代码是对是错。现在校验的结果,这个/etc/profile的代码应该是正确的。
同时我直接从X window system开始的,我可以保证那章的代码都是正确的。我是“参照”那些代码做出了我自己的X window。
最后,谁都不是高手。只是有时候可能用词不当,或者热心过头而已。望见谅!
cat temp
# Begin /etc/profile
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
# System wide environment variables and startup programs.
# System wide aliases and functions should go in /etc/bashrc. Personal
# environment variables and startup programs should go into
# ~/.bash_profile. Personal aliases and functions should go into
# ~/.bashrc.
# Functions to help us manage paths. Second argument is the name of the
# path variable to be modified (default: PATH)
pathremove () {
local IFS=':'
local NEWPATH
local DIR
local PATHVARIABLE=${2:-PATH}
for DIR in ${!PATHVARIABLE} ; do
if [ "$DIR" != "$1" ] ; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
fi
done
export $PATHVARIABLE="$NEWPATH"
}
pathprepend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="$1${!PATHVARIABLE:+ {!PATHVARIABLE}}"
}
pathappend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
}
# Set the initial path
export PATH=/bin:/usr/bin
if [ $EUID -eq 0 ] ; then
pathappend /sbin:/usr/sbin
unset HISTFILE
fi
# Setup some environment variables.
export HISTSIZE=1000
export HISTIGNORE="&:[bf]g:exit"
# Setup a red prompt for root and a green one for users.
NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
if [[ $EUID == 0 ]] ; then
PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
else
PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
fi
for script in /etc/profile.d/*.sh ; do
if [ -r $script ] ; then
. $script
fi
done
# Now to clean up
unset pathremove pathprepend pathappend
# End /etc/profile |
|