use chmod() instead of fchmod() for mingw.
clear escape history after a successful match.
clear escape history after a successful match.