On Sat, 19 Dec 2015 19:24:17 +0100 Ulrich Mueller <[email protected]> wrote:
> >>>>> On Sat, 19 Dec 2015, Michał Górny wrote:
>
> >> + set -f # disable filename
> >> expansion in echo arguments
> >> echo -e ${DOC_CONTENTS} | fold -s -w 70 \
> >> | sed 's/[[:space:]]*$//' >
> >> "${T}"/README.gentoo
>
> > Maybe I'm missing something but is there any reason not to quote
> > "${DOC_CONTENTS}" instead of working around the results of not
> > quoting it?
>
> IIUC the intention of not quoting it is to normalise whitespace,
> especially embedded newlines. Unfortunately, I don't see a good way to
> do this differently. Adding another processing step after echo -e is
> too late, because newlines expanded from \n must be kept.
read -d '' -r -a DOC_CONTENTS <<<"${DOC_CONTENTS}"
This performs word splitting into an array. Then you can do:
echo -e "${DOC_CONTENTS[*]}" | ...
--
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
pgpLXLRlgsTvE.pgp
Description: OpenPGP digital signature
