safe script parameters
I don't know if this is really a programming question, it's more about how to do parameter handling safely in scripts.
I have a script that takes one parameter that's supposed to be a filename, e.g.:
echo $1 >logs/processed-files.log
tar -rf tarfiles/stuff.tar $1
This failes when there is a space in a filename. So a dirty fix is to use "$1" instead. But what about e.g.
./myscript.sh "\" ; rm * ; \""
PHP has a function called EscapeShellArg for this, so I guess it's a common problem.
What's the proper Unix way of doing this? Some sed magic?