A more better solution (IMHO) is:
Code:
#!/bin/bash
foo ()
{
for ARG in "$@"
do
echo $ARG
done
}
# try it out
foo a b "c d" 'e f'
The output produced is:
If you instead use $*, the output changes as follows:
Code:
foo ()
{
for ARG in $*
do
echo $ARG
done
}
foo a b "c d" 'e f'
Output:
a
b
c
d
e
f