[Top][All Lists]

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

Re: read fails on null-byte: v4.1.7 FreeBSD 8.0 (amd64)

From: Chet Ramey
Subject: Re: read fails on null-byte: v4.1.7 FreeBSD 8.0 (amd64)
Date: Tue, 29 Nov 2011 09:39:21 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 11/29/11 8:29 AM, Greg Wooledge wrote:

> There are many bash scripts in use already that rely on read -d '' to
> work the way it does.  Switching the behavior of -d '' and introducing
> -d '\0' in its place would require rewriting all of those scripts.
> The final decision is Chet's, but losing the ability to read a
> NUL-delimited stream would be a huge problem for me.  Neither POSIX sh
> nor ksh has the ability to handle NUL-delimited input, as far as I have
> been able to determine.  I don't know zsh, so maybe it does, or maybe not.

It's possible to have both.  You can handle matching a NUL delimiter and
skip NUL bytes in the input if the delimiter isn't NUL.  That allows the
bash behavior and compatibility with other shells that don't provide `-d'.

There is already `read -n 1' to read only a single character from the input
stream.  I don't see much value in translating '\0' to 0 for `-d'.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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