Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: issues with ${array[x][y]}



On Mar 6,  3:16pm, Stephane Chazelas wrote:
} Subject: issues with ${array[x][y]}
}
} $ a=(foo bar)
} $ x='a[1][1]'
} $ echo ${(P)x}
} foo

This is happening because ${{(P)var}[1]} must treat ${(P)var} as an array
any time the name referred to by $var is an array, so array-ness is being
preserved when doing the first a[1] dereference.

} There's also a consistency issue in that one can do:
} 
} string[1]=x
} 
} and reference ${array[1][1]}
} 
} but:
} 
} $ a[1][1]=b
} zsh: no matches found: a[1][1]=b

Having ${array[1][1]} is mostly for convenience, because it dates from
before ${${array[1]}[1]} would have been syntactically valid.  It was
never intended to work as an assignment.



Messages sorted by: Reverse Date, Date, Thread, Author