[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regression -- can't read input w/stderr redirect

From: Greg Wooledge
Subject: Re: Regression -- can't read input w/stderr redirect
Date: Tue, 20 Jun 2017 08:25:21 -0400
User-agent: Mutt/

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

> * 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

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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]