This is not perfect protection against special chars that the shell may interpret, but should help at least in case $name contains spaces.