Bash parameter expansion $ {parameter ## word}
I am reading through an apache startup script trying to fix some problems with my server, but there is a parameter expansion at the very beginning that I really don't understand.
SCRIPTNAME="${0##*/}"
SCRIPTNAME="${SCRIPTNAME##[KS][0-9][0-9]}"
if [ -n "$APACHE_CONFDIR" ] ; then
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
DIR_SUFFIX="${APACHE_CONFDIR##/etc/apache2-}"
else
DIR_SUFFIX=
fi
elif [ "${SCRIPTNAME##apache2-}" != "$SCRIPTNAME" ] ; then
DIR_SUFFIX="-${SCRIPTNAME##apache2-}"
APACHE_CONFDIR=/etc/apache2$DIR_SUFFIX
else
DIR_SUFFIX=
APACHE_CONFDIR=/etc/apache2
fi
I'm just looking for some clarification on what the $ {parameter ## word} construct is because the bash reference manual from gnu is incomprehensible to me. The manual defines it like this:
$ {parameter # word} $ {parameter ## word}
the word is expanded to create a pattern in the same way as with filename extension (see Filename Extension). If the pattern matches the beginning of the extended parameter value, then the result of the extension is the extended parameter value with the shortest ("# case" pattern) or longest match pattern ("## case"). If the parameter is '@ or' *, the wildcard deletion for each positional parameter is applied in turn, and the expansion is the resulting list. If the parameter is an array variable with the "@ or" * index, the operation of deleting the template is applied to each member of the array in turn, and the expansion is the resulting list.
does this mean that the first line stores the empty string back in SCRIPTNAME
or am I just from base?
source to share