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: 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.
> 
> address@hidden:~$ while IFS= read -r -d '' foo; do echo "<$foo>"; done < 
> <(printf 'one\0two\0')
> <one>
> <two>
> address@hidden:~$ 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




reply via email to

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