bug-bash
[Top][All Lists]
Advanced

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

Re: [PATCH] rev: fix some issues


From: Chet Ramey
Subject: Re: [PATCH] rev: fix some issues
Date: Fri, 8 May 2026 09:09:02 -0400
User-agent: Mozilla Thunderbird

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    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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