Correctly quote input variables

Apparently I put this version online without actually testing, so now it
does not blow up when your regular expression or path contains blanks.