$@ instead of $* in bash functions
#!/bin/bash
# $* is a single string whereas $@ is an array.
# Using "$*"
for a in "$*"; do
echo $a;
done
# Result:
# one two three four
#-------------------------
# Using $*
for a in $*; do
echo $a;
done
# Result:
# one
# two
# three
# four
#-------------------------
# Using "$@"
for a in "$@"; do
echo $a;
done
# Result:
# one
# two
# three four
#-------------------------
# Using $@
for a in $@; do
echo $a;
done
# Result:
# one
# two
# three
# four