properly handle paths with spaces and quote character in them