fixes for replacewdir: replace the first match only