${(P)…}
: Parameter name indirection
${(P)name}
interprets the value of name
as further parameter name and then evaluates it.
Links
Examples
- Using parameter name indirection
- Output:
1 2 3 4 5 6
declare -A data=([key]=value [key2]=value2) name=data # Prints array 'data' echo ${(P)name} # Prints value of `key2` or array `data` echo ${${(P)name}[key2]}
1 2
value2 value value2
BashSupport Pro is a Zsh IDE with support for ${(P)…} – try it now!