Bash Startup Files

From CBLFS
Revision as of 10:27, 3 September 2006 by Jciccone (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

/etc/profile

cat > /etc/profile << "EOF"
# Begin /etc/profile
# Based on the profile scripts in BLFS http://www.linuxfromscratch.org/blfs/view/svn/postlfs/profile.html

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"
}

for script in /etc/profile.d/*.sh
do
  source $script
done
unset script

# End /etc/profile.d
EOF
install -d -m755 /etc/profile.d