zsh-workers
 help / color / mirror / code / Atom feed
* Treating $(...) as an array
@ 1996-06-22 22:27 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 1996-06-22 22:27 UTC (permalink / raw)
  To: zsh-workers

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"



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-06-22 22:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-06-22 22:27 Treating $(...) as an array Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).