2 if [ "$BASH_VERSION" ]; then
3 replaceall() # $var_to_get $find $replace [$var_to_set]
5 eval ${4:-$1}=\"\${$1//\$2${3:+/\$3}}\"
8 # NB: On FreeBSD, sh(1) runs this faster than bash(1) runs the above
9 replaceall() # $var_to_get $find $replace [$var_to_set]
11 eval local __left= __right=\"\$1\" || return
13 case "$__right" in *$2*)
14 __left="$__left${__right%%$2*}$3"
15 __right="${__right#*$2}"
20 __left="$__left${__right#*$2}"
21 eval ${4:-$1}=\"\$__left\"
24 eval echo \"before=[\$1]\"
26 eval echo \" after=[\${4:-$1}]\"