Re: RFC PATCH 1/2] AS_INIT: try to ensure fds 0, 1, 2 are open

Zack Weinberg <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.patches
Message-ID <CAKCAbMi3nyqw-WM8G+Ug7XHyv+pYVNrk7n6Andqwf=EUFMah0Q@mail.gmail.com>
On Thu, Aug 27, 2020 at 2:09 PM Paul Eggert <[email protected]> wrote:
>
> > +  if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
> > +  if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
> > +  if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
>
> This is all _AS_ENSURE_STANDARD_FDS needs to do; none of the other stuff is
> needed and I suggest omitting it as a maintenance time-sink.

I can definitely see how the rest of it could turn into a maintenance
time sink, but are you sure we don't need a workaround of any kind for
this construct succeeding even though the target fd is closed, in very
old shells?  I wouldn't be concerned for almost anything else, but
this is the _generated configure scripts_ we're talking about here.
Coping with very old shells is a big part of why they exist still, and
are still shell scripts.

> not that 'read' from 0 or 'write' to 1 or 2 must succeed (there's never any guarantee of that).

I'm not 100% convinced by this argument but I don't have a real
counterargument either and in any case it's more on-topic for the
glibc thread, not here.

zw
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.