On Tue, Jun 20, 2017 at 02:01:51AM -0700, L A Walsh wrote:
> * BASH???s ???read??? built-in supports '\0' as delimiter
Yes, but not with that syntax. It uses the -d '' option,
which is undocumented, but supported according to
<https://lists.gnu.org/archive/html/bug-bash/2016-01/msg00121.html>.
> * And a line is by definition terminated by ascii 0, right? Newline, for
> instance, is just a formatting character?
No, that isn't a correct statement. A "line" is terminated by a newline.
However, there are some input sources that don't use lines. Instead,
they use records terminated by NULs.
Once upon a time, such input sources were rare. The original Bourne
and POSIX shells have no facilities for working with these inputs.
But bash does.
> (an apple-darwin user - stackoverflow (SO))
> * marked as 'answer' method to read null terminated lines:
> |while IFS= read -r -d '' line ; do ... done <<<"$var" (also SO)
That's just plain wrong. Don't believe everything you read on
stackoverflow.
A bash variable cannot contain a NUL byte, so <<<"$var" is never going
to have NULs in it.
> * support for "-d '' " as equivalent to specifying null termination:
I cited Chet above. That's the most official word we have.
> * "The man page of bash reads: '-d delim The first character of
[...]
It's not in the man page.