Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Fwd: more splitting travails
On Fri, Jan 12, 2024 at 12:32 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> % vvar=("${(@f)"$(<testfile2)"}")
>
> ... and that's not as Byzantine as it looks: " (@f) : read: "include blank lines, and split on newlines (including empty lines) " ... Yes?
Close. It's the inner double quotes around $(<...) that preserve the
exact contents of the file.** (f) means split on newlines and (@)
means "this is an array, don't join it into a string". Then the
outermost set of double quotes means "include empty array elements"
(which, because of (f), is empty lines in this case).
** Except that $(...) trims off TRAILING newlines, so if the last
line(s) of the file are blank they'll vanish.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author