Description of Problem: When you initialise an array using ARRAY=($@) the variables get expanded as if you had used $*. Version-Release number of selected component (if applicable): bash-2.05a-13 How Reproducible: Always Steps to Reproduce: 1. Run attached script Actual Results: Script prints. 2 3 3 3 3 Expected Results: Script prints. 2 2 3 2 3 Additional Information: Here is the script... #! /bin/bash function f() { A=($@) B=($*) echo $# echo ${#A[@]} echo ${#B[@]} echo ${#A[*]} echo ${#B[*]} } f a "b c"
You forgot to quote $@.