[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trailing newlines disappear

From: Greg Wooledge
Subject: Re: Trailing newlines disappear
Date: Thu, 8 Jun 2017 15:14:40 -0400
User-agent: Mutt/

On Fri, Jun 09, 2017 at 01:52:44AM +0700, Peter & Kelly Passchier wrote:
> On 09/06/2560 00:42, Greg Wooledge wrote:
> > foo=$(cat "$file"; printf x) foo=${foo%x}
> The workaround I came up with is:
> mapfile <"$file"; IFS= address@hidden
> This seems to be faster, but it probably has other disadvantages...

Well, it leaves IFS changed, because you didn't revert or unset it,
or run the entire thing in a function with local IFS.  Also, I'd use
"${MAPFILE[*]}" to reinforce that you are joining an array into a string,
rather than expanding the array as a list.  Semantically, x=$@ is pretty
"huh??" to me.

It also leaves the array in memory, and requires bash 4.  Those may not
be significant.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]