bliven@atherton.com (Andy Bliven) (12/15/89)
This is a bug that I posted to newsgroup gnu.util.bug: some netter rather
high-handedly (and incorrectly) told me to post it to gnu.bash.bug, but with
prompting sent along info pointing to this mail alias.
There is a difference in the way bash and sh handle "$@" in a function. Here
is an example in sh:
$ args () { for a in "$@"; do echo $a; done }
$ args 1 2 3 4
1
2
3
4
$
And the same example in bash:
$ args () { for a in "$@"; do echo $a; done }
$ args 1 2 3 4
1 2 3 4
$
Clearly the "$@" is NOT handled differently from "$*" in the latter example.
I'm running on a Sun 3/60 with Sun UNIX 4.2 Release 3.5, and the version is
"GNU bash, version 1.03.4". After some experimentation I discovered that
eliminating the quotes is an acceptable workaround in my application, but if
your goal is 100% compatibility this is probably worth fixing. It took me a
while to figure out just what was going wrong.
Andy Bliven
-------------------------------------------------------------------
Atherton Technology mail: bliven@atherton.com
1333 Bordeaux Drive phone: 408-734-9822
Sunnyvale, California 94089 fax: 408-744-1607