- Array target: ${!nameref:0:n} silently SKIPS the indirect
expansion entirely and instead behaves as if the expression were
${array[0]:0:n} (i.e., nameref is transparently resolved, the
first array element is returned, and substring is applied to it).
Nothing is skipped. Bash performs the nameref expansion, resulting in
${arr:0:100}.
Nameref expansion applies to the `parameter' part of the word expansion,
which in this case is a variable name.
Since the array variable is used without a subscript, it's equivalent to
arr[0].
You would see this if you tested with
${arr:0:100}.
This inconsistency is not documented anywhere in the Bash manual.
The Arrays section says:
"Referencing an array variable without a subscript is equivalent to ref-
erencing the array with a subscript of 0."
The manual section on indirect expansion (Parameter Expansion) does
not mention any distinction based on the type of the referenced
variable.
"If parameter is a nameref, this expands to the
name of the parameter referenced by parameter"
The rest follows from how an array variable is expanded.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/