[Top][All Lists]

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

Re: Why does "mapfile -d delim" (delim != '\n') use unbuffered read?

From: Chet Ramey
Subject: Re: Why does "mapfile -d delim" (delim != '\n') use unbuffered read?
Date: Tue, 4 May 2021 16:49:55 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0

On 5/4/21 4:05 PM, Robert Elz wrote:
     Date:        Tue, 4 May 2021 09:28:04 -0400
     From:        Chet Ramey <chet.ramey@case.edu>
     Message-ID:  <c8b1b097-d430-e840-017d-52a1a6a393d0@case.edu>

   | The issue with the BSDs and terminal devices is that the current code
   | only checks for -1/ESPIPE, but they return a different value for errno
   | (EINVAL? I forget.)

On traditional unix, since forever, lseek() on a terminal is simply a no-op.
(The seek() sys call that preceded it, on 6th edition and earlier was the
same.) No error, no effect -- or no useful effect, the "file offset" might
get set, so you can't even:
        pos = lseek(0,somewhere,0);
        if (lseek(0, pos, 0) != somewhere)
                /* unseekable */
as that would probably (seem to) succeed, but terminals don't use it.

Yeah, it looks like fstat/S_ISREG is the most portable mechanism.

``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]