Quoting parameters in a bash script

For some reason, bash doesn't escape script parameters when executing a script. So, for example, if you have a script parameters.sh containing:

./test $*

… when called with parameters.sh p1 "p2 p2" p3, it will be similar to calling ./test p1 p2 p2 p3, thus ignoring the fact that we're sending 3 parameters, not 4.

To work around this issue, bash provides "$@". Using "$@" is similar to "$1" "$2" "$3" ..., so if we rewrite the above script to use this special parameter

./test "$@"

… when called with parameters.sh p1 "p2 p2" p3, it will now correctly be similar to calling ./test "p1" "p2 p2" "p3".