Shell: Correctly escape single and double quotes in commands