NB: I've read the answers to other similar questions (How to split the output and store it in an array?, How to split a string into an array in bash), but none of them answer the specific question I'm asking here.
Suppose that the output of some command foo is a single line consisting of 10 tab-separated fields. Then
tmpvar=$( foo )
fields=( ${(ps:\t:)tmpvar} )
echo $#fields
# 10
Q: How can I achieve the same splitting of foo's output on tabs without needing an intermediate assignment to tmpvar?
FWIW, this does not work:
fields=( ${(ps:\t:)$( foo )} )
echo $#fields
# 1
set -fdoes something else inzsh(and command substitution doesn't undergo globbing there). Inzshlike inksh93, if you want word-splitting on TAB while preserving empty elements, you can useIFS=$'\t\t'. Using thesvariable expansion flag is a lot better than changing a global setting IMO. Also note that the-eis implicit inzsh. – Stéphane Chazelas Apr 18 '17 at 13:14