make scripts work with spaces in paths and fix a undefined warning