string replacement turns out not POSIX compliant

I found out about this when testing nvm in dash/sh without curl.

See also: #477 

http://mywiki.wooledge.org/Bashism