I think this is wrong: var= ; echo "${var/*/x}"
It should print x but it prints nothing.
The attached patch fixes this, I hope it's ok.
I don't know what's the correct behaviour in case $var is unset, but it's
probably worth to look at, since bash prints nothing in that case too.
---
xoxo iza