I'm having hard time understanding difference between $@
and $*
when passing them to functions.
Here is example:
function a {
echo "-$1-" "-$2-" "-$3-";
}
function b {
a "$@"
}
function c {
a "$*"
}
If calls:
$ b "hello world" "bye world" "xxx"
It prints:
-hello world- -bye world- -xxx-
If calls:
$ c "hello world" "bye world" "xxx"
It prints:
$ c "hello world" "bye world" "xxx"
-hello world bye world xxx- -- --
What happened? I can't understand difference and what went wrong.