[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trailing newlines disappear
From: |
Geir Hauge |
Subject: |
Re: Trailing newlines disappear |
Date: |
Thu, 8 Jun 2017 22:44:29 +0200 |
User-agent: |
NeoMutt/20161126 (1.7.1) |
On Fri, Jun 09, 2017 at 03:34:39AM +0700, PePa wrote:
> On 09/06/2560 02:14, Greg Wooledge wrote:
> > 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.
>
> Thanks for pointing all this out. I settled on:
> mapfile <"$file"; IFS= foo=${MAPFILE[*]} true
Greg already pointed out that this doesn't work.
You can pick one of these instead:
mapfile < "$file"; IFS= foo="${MAPFILE[*]}"; unset -v IFS
or
mapfile < "$file"; printf -v foo %s "${MAPFILE[@]}"
--
Geir Hauge
- Trailing newlines disappear, PePa, 2017/06/08
- Re: Trailing newlines disappear, Greg Wooledge, 2017/06/08
- Re: Trailing newlines disappear, Peter & Kelly Passchier, 2017/06/08
- Re: Trailing newlines disappear, PePa, 2017/06/08
- Re: Trailing newlines disappear,
Geir Hauge <=
- Re: Trailing newlines disappear, Peter & Kelly Passchier, 2017/06/08
- Re: Trailing newlines disappear, Greg Wooledge, 2017/06/08
- Re: Trailing newlines disappear, Eduardo Bustamante, 2017/06/08
- Re: Trailing newlines disappear, Peter & Kelly Passchier, 2017/06/08
- Re: Trailing newlines disappear, Greg Wooledge, 2017/06/09
- Re: Trailing newlines disappear, Chet Ramey, 2017/06/09
- Re: Trailing newlines disappear, Greg Wooledge, 2017/06/09
- Re: Trailing newlines disappear, Chet Ramey, 2017/06/09
- Re: Trailing newlines disappear, L A Walsh, 2017/06/09
- Re: Trailing newlines disappear, Peter & Kelly Passchier, 2017/06/09