PATH=\
/local/bin:\
~/bin:\
$PATH
if [ "$HOSTNAME" = server ]; then
PATH=\
/usr/sbin:\
$PATH
fi
Using arrays, we can clean up this script.
saveIFS=$IFS
IFS=':'
IFS=':'
apath=(
/local/bin
~/bin
$PATH
)
/local/bin
~/bin
$PATH
)
if [ "$HOSTNAME" = server ]; then
apath=(
apath=(
/usr/sbin
${apath[@]}
)
${apath[@]}
)
fi
apath=(${apath[@]})strpath="${apath[*]}"
IFS=$saveIFS
PATH=$strpath
No comments:
Post a Comment