[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: read Built-in Parameter Behavior -- Null Byte Delimiter
From: |
Greg Wooledge |
Subject: |
Re: read Built-in Parameter Behavior -- Null Byte Delimiter |
Date: |
Mon, 18 Jan 2016 11:25:49 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Mon, Jan 18, 2016 at 11:16:06AM -0500, Chet Ramey wrote:
> On 1/18/16 8:14 AM, Greg Wooledge wrote:
> > 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'.
Happy coincidence, then.
> 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.
Other shells must go out of their way to suppress it, then.
wooledg@wooledg:~$ while IFS= read -r -d '' foo; do echo "<$foo>"; done <
<(printf 'one\0two\0')
<one>
<two>
wooledg@wooledg:~$ ksh
$ while IFS= read -r -d '' foo; do echo "<$foo>"; done < <(printf 'one\0two\0')
$ while IFS= read -r -d x foo; do echo "<$foo>"; done < <(printf 'onextwox')
<one>
<two>
- read Built-in Parameter Behavior -- Null Byte Delimiter, Adam Danischewski, 2016/01/16
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Piotr Grzybowski, 2016/01/16
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Martijn Dekker, 2016/01/16
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Greg Wooledge, 2016/01/18
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Chet Ramey, 2016/01/18
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter,
Greg Wooledge <=
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Chet Ramey, 2016/01/18
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Adam Danischewski, 2016/01/19
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Greg Wooledge, 2016/01/19
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Adam Danischewski, 2016/01/19
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Greg Wooledge, 2016/01/19
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Reuti, 2016/01/25
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Greg Wooledge, 2016/01/25
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Reuti, 2016/01/30
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Stephane Chazelas, 2016/01/18
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Stephane Chazelas, 2016/01/18