Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Treating $(...) as an array
- X-seq: zsh-workers 1425
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: Treating $(...) as an array
- Date: Sat, 22 Jun 1996 15:27:26 -0700
- Reply-to: schaefer@xxxxxxx
You can force $(...) to be interpreted as an array when assigning it to a
variable:
zsh% x=($(print -l "One two" "Three four" "Five six"))
zsh% echo $#x
6
You can force a string variable to be interpreted as an array:
zsh% x="$(print -l "One two" "Three four" "Five six")"
zsh% echo ${x[2]} ${x[(w)2} ${x[(f)2]}
n two Three four
You can use $(...) as a string substitution inside ${...}:
zsh% echo ${(L)$(print -l "One two" "Three four" "Five six")}
one two three four five six
You can use modifiers on $(...) when it appears as a string substitution:
zsh% echo ${$(print -l "One two" "Three four" "Five six"):l}
one two three four five six
So, WHY can't you force $(...) to be interpreted directly as an array
when it appears as a string substitution?
zsh% echo ${$(print -l "One two" "Three four" "Five six")[(f)2]}
zsh: closing brace expected
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.nbn.com/people/lantern
New male in /home/schaefer:
>N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author