Listing 4: Setting PATHs in bash

  1	directories="
  2		$HOME
  3		$HOME/binutils-2.5.2
  4		/usr/X11R6
  5		/usr/local
  6		/usr/X11
  7		/usr
  8		/
  9	"
 10
 11	temp_path=""
 12	temp_manpath=""
 13	temp_infopath=""
 14
 15	for i in $directories
 16	do
 17		if [ -d $i/bin ]; then
 18			if [ -z $temp_path ]; then
 19				temp_path=$i/bin
 20			else
 21				temp_path=$temp_path:$i/bin
 22			fi
 23		fi
 24
 25		if [ -d $i/info ]; then
 26			if [ -z $temp_infopath ]; then
 27				temp_infopath=$i/info
 28			else
 29				temp_infopath=$temp_infopath:$i/info
 30			fi
 31		fi
 32
 33		if [ -d $i/man ]; then
 34			if [ -z $temp_manpath ]; then
 35				temp_manpath=$i/man
 36			else
 37				temp_manpath=$temp_manpath:$i/man
 38			fi
 39		fi
 40
 41	done
 42
 43	export INFO_PATH=$temp_infopath
 44	PATH=$temp_path
 45	export MANPATH=$temp_manpath
 46	unset temp_manpath temp_path temp_infopath

