[Top][All Lists]

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

Re: Option for read to handle incomplete last line

From: Chet Ramey
Subject: Re: Option for read to handle incomplete last line
Date: Sun, 24 Oct 2021 12:42:17 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

On 10/24/21 12:22 PM, Martin Schulte wrote:

Before reading the source I would never have thought that read sets variables 
although it returns FAILURE.

Think of them as orthogonal conditions. `read' reads until a newline, or
EOF or other error condition (ignoring timeouts or reading N characters for
a minute), storing the characters it reads into the variable(s).

The variable(s) continue(s) to hold the characters read. `read' returns a
status dependent on the status of the last read(2). If it gets EOF (or
error), the return status is > 0, but the characters read are not lost.

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

reply via email to

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