-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 12/19/2015 05:56 PM, Michał Górny wrote:
> On Sat, 19 Dec 2015 23:51:47 +0100 Ulrich Mueller <[email protected]>
> wrote:
> 
>>>>>>> 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.
> 
> On WHAT?!
> 

Apparently, bash(1) and bash.info don't document what it means to pass
an empty string as the argument to the -d option of the read builtin
(what actually happens is that in all cases, bash uses the first
character of the C string that the option gets translated to, which is
'\0' for the empty string; the documentation just refers to "the first
character of the string passed").

- -- 
Jonathan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCgAGBQJWdeydAAoJEEIQbvYRB3mgnQ4P+gP6WHxcyb6PZaBo8EG3nj/i
I5mbIs4XSsp4G13SVm54nTQelPzDlDLtMsRqdAj5Oh+oXrCyLLFcUKSpUf/1laNG
z7pzY6FStgFm1MZWAajtw16xr1+tAbkmGbGy/6pYvSVu7yNiI1n/P+2tBij6e6rN
cOeLtqRGfb1M0Ew3Py2qKVmWYf+/YxH6AkwFZGBZRcb+q3lCSZ9Ycbk3GRBStZwG
wi3PAf6nnuEaouuk7GA33Fi35cmHs8MISVIC70ULakOTu51xHm7aVJCzZQQIFl9N
WvH04+IMCcX+BleU6mP4LK0NB647WwKR8JWgcl8qj2415RvvImCtE35bhnpJbf92
PcVP1l4NJzbUUyfXMDZBpvxzXMHTz2DA4b9PS5Mq8jhiA1jKqAWFD5BBG05SHyrA
IpD0CKipLUFsXyJ5z/MS0gmUFFwymhB+dBVtKOqa4a4s40H2qahY3ffyn/MzIx52
imAYb7IK4MqCPQrzr9nM7qf7UApyLEaQDjN5n+bJ4ZEEd+p3kdf2sVrAFdTom0SU
hXmF1+7TCW4pVB6kL35YbtJkKQbHPfXTHVAJ/ctsLMMNNzXSiKUdnlCV+CwWfrgC
ptMy/Rk7WoHssyQZgl83JsQBdz396j0M6M3+kUNSGFThCz3OF9YBAccrKy7gqeHr
cyg+QQQN4yNyFaWl7S9a
=5O6Z
-----END PGP SIGNATURE-----

Reply via email to