Consider the following code:
foo () {
echo $*
}
bar () {
echo $@
}
foo 1 2 3 4
bar 1 2 3 4
It outputs:
1 2 3 4
1 2 3 4
I am using Ksh88, but I am interested in other common shells as well. If you happen to know any particularity for specific shells, please do mention them.
I found the follwing in the Ksh man page on Solaris:
The meaning of $* and $@ is identical when not quoted or when used as a parameter assignment value or as a file name. However, when used as a command argument, $* is equivalent to ``$1d$2d...'', where d is the first character of the IFS variable, whereas $@ is equivalent to $1 $2 ....
I tried modifying the IFS
variable, but it doesn't modify the output. Maybe I'm doing something wrong?