In zsh, if I run:
a=$(echo "foo, bar")
echo ${a[(ws:, :)1]}
I get foo
as you would expect (w
causes the index to refer to words s:, :
makes ,
be the word separator).
However, if I try to combine these:
echo ${$(echo "foo, bar")[(ws:, :)1]}
I get foo,
. For some reason the w
flag is working correctly, but the s:, :
flag is completely ignored.
What am I doing wrong here?
More info: This is just a problem with $() inside ${}. If I nest ${} inside ${} there is no such problem.
$ zsh --version
zsh 5.2 (x86_64-unknown-linux-gnu)