On 5/7/26 4:55 PM, Duncan Roe wrote:

The original code is correct. The effect of including this patch is that rev
with no arguments is a no-op. rev with no arguments *should* read lines from
standard input (fd 0).

You're both right. If fd 0 is closed for some reason when `rev' is invoked
with a filename argument, the open() will return file descriptor 0 and the
original code will leave it open. Since it's a builtin, the open file
descriptor will persist in the shell execution environment.

The usual fix is to use a flag that tells whether the file descriptor is
the inherited stdin or the result of open(). I added that yesterday.

Chet

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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to