>>>>> On Sat, 19 Dec 2015, Michał Górny wrote:

>> (I guess it is encountering EOF on the temporary file created by
>> the string redirection, but how would one distinguish this from
>> other errors?)

> read's return code indicates whether if found a full line (with a
> newline). read can't really fail.

Certainly writing or reading the temp file can fail?

>> Besides, it is hard to understand what this code does, as compared
>> to the "set -f" solution.

> Many pieces of good code are harder to understand than cheap, ugly
> hacks. That's why those hacks are so common, and people meet them
> all the time and never learn good code.

Well, compare:

    set -f
    echo -e ${DOC_CONTENTS} | ...

versus:

    read -d '' -r -a DOC_CONTENTS <<<"${DOC_CONTENTS}"
    echo -e "${DOC_CONTENTS[*]}" | ...

The second one is (IMHO) harder to understand, less efficient, and
relies on undocumented behaviour.

Ulrich

Attachment: pgpKGa5qZlTyR.pgp
Description: PGP signature

Reply via email to