bug-bash
[Top][All Lists]
Advanced

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

Re: read Built-in Parameter Behavior -- Null Byte Delimiter


From: Chet Ramey
Subject: Re: read Built-in Parameter Behavior -- Null Byte Delimiter
Date: Mon, 18 Jan 2016 11:16:06 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 1/18/16 8:14 AM, Greg Wooledge wrote:
> On Sat, Jan 16, 2016 at 02:28:27PM -0500, Adam Danischewski wrote:
>> If it is expected behavior I didn't see it in the documents.
> 
> I suspect the interpretation of -d '' to mean a NUL byte delimiter
> may have been an accident originally (but that's a guess).

I guess that depends on what you mean by `accident'.  There's nothing
special in the code that checks for NUL; it's just another delimiter
and another value returned by read(2).  There's no reason it should
not just work.

> But it's
> an incredibly useful feature, and has been used in countless real
> life scripts.  At this point, while it is still undocumented, it is
> nevertheless a feature whose omission would be considered a regression.

It's not a special case that needs to be documented as such.  It's a
straightforward application of the rules for assigning the delimiter
and reading it.  You do have to understand how C strings work and how
they are used when passing arguments to commands for it to make sense.

Chet


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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