substituteStream() {
local var=$1;
local description=$2;
shift 2;
while (( "$#" )); do
case "$1" in
--replace)
pattern="$2";
replacement="$3";
shift 3;
local savedvar;
savedvar="${!var}";
eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}';
if [ "$pattern" != "$replacement" ]; then
if [ "${!var}" == "$savedvar" ]; then
echo "substituteStream(): WARNING: pattern '$pattern' doesn't match anything in $description" 1>&2;
fi;
fi
;;
currently,
substituteStream
runs the replace if pattern and replacement are equalso currently, this is *not* a noop
actual