bug-bash
[Top][All Lists]
Advanced

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

Re: read command and ascii null as delimiter


From: Chet Ramey
Subject: Re: read command and ascii null as delimiter
Date: Fri, 08 Sep 2006 11:49:05 -0400
User-agent: Thunderbird 1.5.0.5 (Macintosh/20060719)

Nathan Coulter wrote:
> Feature request: an option, maybe "-0" to use ascii null as the delimiter for 
> the "read" command.  It would make the following two commands produce the 
> same output:
> 
> pooryorick@debian:~/tmp5$ printf 'hello\000there' | xargs -n1 -0 echo
> hello
> there
> 
> pooryorick@debian:~/tmp5$ printf 'hello\000there' | { while read -0 ; do echo 
> $REPLY; done; }

read -d $'\0' will do most of what you want, with one limitation.  The
read builtin accepts only one eol delimiter, so either you ensure that
the input ends with a NUL or you pick up the final portion of the input
in $REPLY after read returns status 1 upon encountering EOF.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
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]