Passing the command $@ passes all the arguments to the command. If the argument contains a space, the command will see this argument as two separate.
Passing the $ @ command to the command passes all arguments as quoted strings to the command. The command will see the argument containing spaces as the only argument containing spaces.
To easily visualize the difference, write a function that prints all of its arguments in a loop, one at a time:
#!/bin/bash loop_print() { while [[ $# -gt 0 ]]; do echo "argument: '$1'" shift done } echo "#### testing with \ $@ ####" loop_print $@ echo "#### testing with \"\ $@ \" ####" loop_print " $@ "
Call script with
<script> "foo bar"
will produce output
source share