Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Fwd: more splitting travails
- X-seq: zsh-users 29455
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Fwd: more splitting travails
- Date: Fri, 12 Jan 2024 14:09:05 -0800
- Archived-at: <https://zsh.org/users/29455>
- In-reply-to: <CAA=-s3x4nkLST56mhpWqb9OXUQR8081ew63p+5sEsyw5QmMdpw@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> <CAA=-s3x4nkLST56mhpWqb9OXUQR8081ew63p+5sEsyw5QmMdpw@mail.gmail.com>
On Fri, Jan 12, 2024 at 1:57 PM Mark J. Reed <markjreed@xxxxxxxxx> wrote:
>
> On Fri, Jan 12, 2024 at 15:52 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>>
>> ** Except that $(...) trims off TRAILING newlines>
>
>I didn't realize *multiple* new lines would get chomped, either; I thought it was just the last one.
Yeah, oddly, there's no straightforward way to get an unaltered file
into a shell variable. Even
read -rd '' < file
trims off trailing newlines. The only somewhat-obvious way is to use
zmodload zsh/mapfile
var=$mapfile[file]
but up until a recent dev version, on platforms that don't implement
memmap that just sneakily reverts to $(<file).
I'm expecting Roman or someone to point out a different trick I've forgotten.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author