bug-bash
[Top][All Lists]
Advanced

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

Re: Bug for the 'read' build in


From: Chet Ramey
Subject: Re: Bug for the 'read' build in
Date: Wed, 9 Nov 2016 14:21:25 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 11/9/16 10:42 AM, Kai Pöritz wrote:

> Bash Version: 4.3
> Patch Level: 48
> Release Status: release
> 
> Description:
> Dear Chet Ramey,
> 
> I think I found a bug in the read build in. I described it at:
> 
> https://savannah.gnu.org/support/index.php?109181
> 
> But I'll write it here again:
> 
> read sets variable on timeout, but should not
> 
> When read is used with the -t option and nothing is entered an unset
> variable should remain unset but it is set:
> 
> $ unset var; read -t 0.5 var; declare -p var
> declare -- var=""
> $ unset var; read -t 0.5 var <<< ''; declare -p var
> declare -- var=""
> $

It's a consequence of this documented behavior:

"If read times out, read saves any partial input read into
the  specified  variable  name."

The idea is twofold: to save partially read input that would otherwise be
lost, and to allow programmers to detect that read timed out rather than
hit EOF (yes, you can check the exit status, too).

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



reply via email to

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