classes.sh
637 Bytes
has_class() {
if [ 1 -ne $# ]
then
logger -p syslog.err 'has_class: no class given'
exit 1
fi
local CHECK=" ${CLASSES}"
test "${CHECK}" != "${CHECK% ${1} *}"
}
##
# add one or more classes given as arguments to this function
# Using ${@} here effectively eliminates multiple spaces between
# the classnames.
# A class might be defined multiple times...I don't eliminate these
# duplicates as this might involve calling uniq which is unneccesary
# overhead as I see no harm in duplicates now.
#
set_class() {
[ -z "${CLASSES}" ] &&
{ CLASSES="${@}"; export CLASSES; } ||
CLASSES="${CLASSES} ${@}"
}
# vim: set ts=4 sw=4: