2 if [ "$BASH_VERSION" ]; then
3 replaceend() # $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 replaceend() # $var_to_get $find $replace [$var_to_set]
11 eval local __string=\"\$1\" || return
12 case "$__string" in *$2)
13 __string="${__string%$2}$3"
15 eval ${4:-$1}=\"\$__string\"
18 eval echo \"before=[\$1]\"
20 eval echo \" after=[\${4:-$1}]\"