[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fflush & close behavior not well-defined
From: |
Andrew J. Schorr |
Subject: |
Re: fflush & close behavior not well-defined |
Date: |
Mon, 14 Sep 2020 09:07:29 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi,
On Sun, Sep 13, 2020 at 11:50:17PM -0600, arnold@skeeve.com wrote:
> Thanks for the report. Gawk's close already takes an optional second
> argument ("from" or "to") for closing one end of a two-way pipe.
True, but if you look at the code in io.c:do_close, you'll see that the from/to
"how" argument does not come into play until after the open file is identified
by scanning the red_head list. So the presence of that argument does not limit
the search to the subset of open pipes. It merely triggers a warning from
io.c:close_redir if used with a file that's not a pipe. So in the case of
close, the fix would require up to 3 arguments:
close(file, [, filetype [, how]])
(with the code being smart enough to detect when "how" is located in the
2nd position).
> If you're willing to hack on the code a bit, I'd have it search the
> full list, and upon finding a second instance of the same string,
> close it also, but with a warning message.
I considered that, but what then would the return value be?
> Otherwise, I think that:
>
> > Or we could just punt and pretend that nobody ever noticed this.
>
> Is the right answer.
Plausibly. So not worth documenting?
As you know, this relates to the other matter we were discussing about the
non-uniqueness of redirection strings and the more general requirement for a
filetype for correct identification. It seemed useful to provide a simple
example of how the current paradigm is slightly broken.
Regards,
Andy
- fflush & close behavior not well-defined, Andrew J. Schorr, 2020/09/13
- Re: fflush & close behavior not well-defined, arnold, 2020/09/14
- Re: fflush & close behavior not well-defined,
Andrew J. Schorr <=
- Re: fflush & close behavior not well-defined, Manuel Collado, 2020/09/14
- Re: fflush & close behavior not well-defined, Andrew J. Schorr, 2020/09/14
- Re: fflush & close behavior not well-defined, Neil R. Ormos, 2020/09/14
- Re: fflush & close behavior not well-defined, Andrew J. Schorr, 2020/09/14
- Re: fflush & close behavior not well-defined, Neil R. Ormos, 2020/09/14
- Re: fflush & close behavior not well-defined, Andrew J. Schorr, 2020/09/14
- Message not available
- Re: fflush & close behavior not well-defined, Andrew J. Schorr, 2020/09/14
- RE: fflush & close behavior not well-defined, pjfarley3, 2020/09/14
- Re: fflush & close behavior not well-defined, Wolfgang Laun, 2020/09/14
Re: fflush & close behavior not well-defined, Lorenz, 2020/09/15