Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
# Wihout quotes, all argument grouping by the script caller is lost
helloWorld $@

# With quotes, argument quoting by the script caller is preserved
helloWorld "$@"

This is because enclosing a variable in double-quotes "" preserves any special formatting internal to the variable's value.


Tip
titleTip

It is a good idea to double-quote bash positional argument variables in order to preserve the caller's quoting.

Corollary: If some argument isn't coming through as you're expecting, it's probably a quoting issue!

...