The ${parameter,,pattern} parameter expansion converts alphabetic characters in parameter to lower-case.
On cygwin 1.7.11-1 Bash 4.1.10(4) and also on my debian squeeze Bash 4.1.5(1);
if i run the following, i get a curious result:
$ declare -a a=(Zero One Two Three); n=0; echo "${a[n],,}->${n}"; echo "${a[++n]}->${n}"; echo "${a[++n],,}->${n}"
zero->0
One->1
three->3
$
NB: similar results happen:
for ,,* or ^^ case conversion;
for some other expansions such as ${parameter##word};
for using either prefix/postfix ++ or -- operator;
for using $((++n)) instead of just ++n.
However, the length expansion ${#parameter} works as i might expect:
in the above snippet, echo "${#a[++n]}->${n}" instead of echo "${a[++n],,}->${n} would yield 3->2 instead of three->3 ~& the length of a[2]="two" is indeed 3 characters.
I imagine that the parameter expansion is happening twice. But why is this happening?
zero->0 One->1 two->2"${a[++n],,}"that should move to the last element but would (per your results) move one past the end of the array.