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