[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trailing newlines disappear
From: |
Peter & Kelly Passchier |
Subject: |
Re: Trailing newlines disappear |
Date: |
Fri, 9 Jun 2017 01:52:44 +0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 |
On 09/06/2560 00:42, Greg Wooledge wrote:
> It's not a bug. This is how command substitution has worked since
> the original Bourne shell.
>
> The workaround is to put something inside the command substitution,
> so that the newlines aren't trailing any more, and then strip it away
> afterward:
>
> foo=$(cat "$file"; printf x) foo=${foo%x}
Thanks for the reply.
Seeing the hackish workaround, I would call it an ossified (or codified)
flaw...
The workaround I came up with is:
mapfile <"$file"; IFS= foo=${MAPFILE[@]}
This seems to be faster, but it probably has other disadvantages...
Peter
- Trailing newlines disappear, PePa, 2017/06/08
- Re: Trailing newlines disappear, Greg Wooledge, 2017/06/08
- Re: Trailing newlines disappear,
Peter & Kelly Passchier <=
- Re: Trailing newlines disappear, PePa, 2017/06/08
- Re: Trailing newlines disappear, Geir Hauge, 2017/06/08
- 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