1 |
On Sat, 19 Dec 2015 23:51:47 +0100 |
2 |
Ulrich Mueller <ulm@g.o> wrote: |
3 |
|
4 |
> >>>>> On Sat, 19 Dec 2015, Michał Górny wrote: |
5 |
> |
6 |
> >> (I guess it is encountering EOF on the temporary file created by |
7 |
> >> the string redirection, but how would one distinguish this from |
8 |
> >> other errors?) |
9 |
> |
10 |
> > read's return code indicates whether if found a full line (with a |
11 |
> > newline). read can't really fail. |
12 |
> |
13 |
> Certainly writing or reading the temp file can fail? |
14 |
> |
15 |
> >> Besides, it is hard to understand what this code does, as compared |
16 |
> >> to the "set -f" solution. |
17 |
> |
18 |
> > Many pieces of good code are harder to understand than cheap, ugly |
19 |
> > hacks. That's why those hacks are so common, and people meet them |
20 |
> > all the time and never learn good code. |
21 |
> |
22 |
> Well, compare: |
23 |
> |
24 |
> set -f |
25 |
> echo -e ${DOC_CONTENTS} | ... |
26 |
> |
27 |
> versus: |
28 |
> |
29 |
> read -d '' -r -a DOC_CONTENTS <<<"${DOC_CONTENTS}" |
30 |
> echo -e "${DOC_CONTENTS[*]}" | ... |
31 |
> |
32 |
> The second one is (IMHO) harder to understand, less efficient, and |
33 |
> relies on undocumented behaviour. |
34 |
|
35 |
On WHAT?! |
36 |
|
37 |
-- |
38 |
Best regards, |
39 |
Michał Górny |
40 |
<http://dev.gentoo.org/~mgorny/> |