On 18/03/2025 12:55, Geoff Clare via austin-group-l at The Open Group wrote:> What I, and I assume most application writers, would expect to happen
in practice is that 0<&0 redirects standard input to come from the
place that standard input already comes from.  In the situation where
standard input is "assigned to an open file description that behaves
as if /dev/null had been opened for reading only" I would expect standard
input to continue to behave like /dev/null after the redirection.

Oh I see, you interpret the & as taking effect first, redirecting stdin as if from /dev/null, and then 0<&0 keeping it that way. But then the "This initial assignment shall be overridden by any explicit redirection of standard input within the AND-OR list." wording is redundant: if it weren't there, that would already be the effect.

The original wording suggested to me that 0<&0 was considered an explicit redirection with unspecified/underspecified behaviour, and that like any other explicit redirection prevents the implicit 0</dev/null from taking place, and then after that, because stdin is still the original stdin, doing the sensible thing for that unspecified/underspecified behaviour, 0<&0 would continue to use the original stdin.

Notable shells that do it this way are bash and ksh, including in POSIX mode, so if a change is made here, that is probably worth calling out explicitly.

Cheers,
Harald van Dijk

  • [1003.1(20... Austin Group Issue Tracker via austin-group-l at The Open Group
    • [1003... Austin Group Issue Tracker via austin-group-l at The Open Group
    • [1003... Austin Group Issue Tracker via austin-group-l at The Open Group
    • [1003... Austin Group Issue Tracker via austin-group-l at The Open Group
      • R... Harald van Dijk via austin-group-l at The Open Group
        • ... Geoff Clare via austin-group-l at The Open Group
          • ... Harald van Dijk via austin-group-l at The Open Group
            • ... Geoff Clare via austin-group-l at The Open Group
              • ... Harald van Dijk via austin-group-l at The Open Group
                • ... Geoff Clare via austin-group-l at The Open Group
                • ... Harald van Dijk via austin-group-l at The Open Group
                • ... Steffen Nurpmeso via austin-group-l at The Open Group
                • ... Chet Ramey via austin-group-l at The Open Group
              • ... Chet Ramey via austin-group-l at The Open Group
            • ... Chet Ramey via austin-group-l at The Open Group
          • ... Lawrence Velázquez via austin-group-l at The Open Group
            • ... Harald van Dijk via austin-group-l at The Open Group

Reply via email to