Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Fwd: more splitting travails
- X-seq: zsh-users 29457
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Fwd: more splitting travails
- Date: Fri, 12 Jan 2024 18:19:50 -0800
- Archived-at: <https://zsh.org/users/29457>
- In-reply-to: <CAH+w=7Y5_oQL20z7mkMUGSLnsdc9ceJ3=QqdAHVRF9jDZ_hZoQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <ca1761f1-6d8f-452a-b16d-2bfce9076e25@eastlink.ca> <CAH+w=7ZJsr7hGRvD8f-wUogPcGt0DMOcPyiYMpcwCsbBNkRwuQ@mail.gmail.com> <CAA=-s3zc5a+PA7draaA=FmXtwU9K8RrHbb70HbQN8MhmuXTYrQ@mail.gmail.com> <CAH+w=7bAWOF-v36hdNjaxBB-5rhjsp97mAtyESyR2OcojcEFUQ@mail.gmail.com> <205735b2-11e1-4b5e-baa2-7418753f591f@eastlink.ca> <CAH+w=7Y5_oQL20z7mkMUGSLnsdc9ceJ3=QqdAHVRF9jDZ_hZoQ@mail.gmail.com>
On 2024-01-12 12:51, Bart Schaefer wrote:
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.**
Yes
(f) means split on newlines
Yup
and (@)
means "this is an array, don't join it into a string".
There's a mistake: I thought the @ was what meant 'all lines'.
Then the
outermost set of double quotes means "include empty array elements"
(which, because of (f), is empty lines in this case).
Nuts, if the innermost quotes say 'exact contents' then that seems
redundant.
And I thought the outermost parenthesis said 'this is an array', not the '@'
** Except that $(...) trims off TRAILING newlines, so if the last
line(s) of the file are blank they'll vanish.
Easy when you know how.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author