[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Interesting article on boot ordering
- From: Chris Adams <cmadams hiwaay net>
- To: rhl-devel-list redhat com
- Subject: Re: Interesting article on boot ordering
- Date: Fri, 19 Sep 2003 16:53:23 -0500
Once upon a time, Bill Nottingham <notting redhat com> said:
> For example, we just in the past day or two got rid of 41 shell invocations
> on boot just by changing how grep was built. Always look for the big wins
> first. :)
Yeah, I've got a bit in my standard profile script that strips out
instances of the "standard" directory from the path and re-adds them at
the beginning in a specified order (so you don't get duplicates, they
are in an expected order, etc.). This used to take forever, but I
managed to make it run entirely with no external calls (including no
forks, no subshells, etc.).
########################################################################
# Set the base PATH here
BASEPATH=/usr/local/bin:/usr/bin:/bin
BASEPATH=$BASEPATH:/usr/X11R6/bin
BASEPATH=$BASEPATH:/usr/games
BASEPATH=$BASEPATH:/usr/local/sbin:/usr/sbin:/sbin
BASEPATH=$HOME/bin:$BASEPATH
# Split the base PATH and PATH into arrays for searching
IFS=":$IFS"
BASEARRAY=($BASEPATH)
PATHARRAY=($PATH)
IFS="${IFS#:}"
# Now remove any instances of the base PATH from the PATH and put them
# at the front
PATH=$BASEPATH
for pdir in ${PATHARRAY[*]}; do
cont=0
for bdir in ${BASEARRAY[*]}; do
if [ "$pdir" = "$bdir" ]; then
cont=1
break
fi
done
[ "$cont" = 1 ] && continue
PATH="$PATH:$pdir"
done
unset BASEPATH BASEARRAY PATHARRAY pdir cont bdir
export PATH
########################################################################
The "BASEARRAY=($BASEPATH)" is a bash specific thing; the same effect
can be had in ksh with "set -A BASEARRAY $BASEPATH", but that is ksh
specific (I don't know of a POSIX shell way of doing that).
It seems like a little thing, but optimizing shell scripts can make a
big difference.
--
Chris Adams <cmadams hiwaay net>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]