Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: read string containing null



> On 21 October 2021 at 13:35 Pier Paolo Grassi <pierpaolog@xxxxxxxxx> wrote:
> Hello, I just found out:
> 
> echo -e - a$'\000'b | IFS='' builtin read -r -d '' xx; echo -n - $xx
> result is "a"
> 
> is it possible for builtin read not to stop an null bytes? I found nothing
> in documentation.
> thanks

I think -d '' is telling it to treat NULL bytes as a delimiter.  Take that out.

If you're not trying to read a line, don't use read.  If you "zmodload zsh/system"
there's a sysread command which is more useful for lower level operations.

pws




Messages sorted by: Reverse Date, Date, Thread, Author