Escape shell characters in query before running