[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: read Built-in Parameter Behavior -- Null Byte Delimiter
From: |
Stephane Chazelas |
Subject: |
Re: read Built-in Parameter Behavior -- Null Byte Delimiter |
Date: |
Mon, 18 Jan 2016 16:52:29 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2016-01-18 11:25:49 -0500, Greg Wooledge:
[...]
> 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>
[...]
zsh behaves like bash here (wrt to '', not in corner cases like:
$ echo 'aéb' | bash -c "read -d $'\xc3' a; echo \$a"
a
$ echo 'aéb' | zsh -c "read -d $'\xc3' a; echo \$a"
aéb
)
Note that zsh supports passing NUL characters to its builtins, so
read -d $'\0' var
does do what it says on the tin there.
ksh93's one seems to be broken with multi-byte characters:
~$ echo 'aéb' | ksh -c 'read -d é a; echo $a'
aéb
~$ echo 'aéb' | ksh -c "read -d $'\xc3' a; echo \$a"
zsh: done echo 'aéb' |
zsh: segmentation fault ksh -c "read -d $'\xc3' a; echo $a"
--
Stephane
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, (continued)
- 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, 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, 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 <=
- Re: read Built-in Parameter Behavior -- Null Byte Delimiter, Stephane Chazelas, 2016/01/18