All of lore.kernel.org
 help / color / mirror / Atom feed
From: Earnestly <zibeon@gmail.com>
To: dash@vger.kernel.org
Subject: Re: Surprising behaviour when reading from a named pipe and standard input
Date: Tue, 10 Feb 2026 10:24:04 +0000	[thread overview]
Message-ID: <aYsHRFz5kAWkcLSb@teapot> (raw)
In-Reply-To: <f13da815-0438-44be-b224-a6f5c5ee4454@gigawatt.nl>

On Tue, Feb 10, 2026 at 02:00:18AM +0000, Harald van Dijk wrote:
> In bash, <&0 suppresses the implicit </dev/null, meaning the outer
> environment's stdin gets used.

I hoped that dash would do the same, when faced with an explicit use
of <&0, which I try to base on my reading of the standard:

> If, and only if, job control is disabled, the standard input for the
> subshell in which an asynchronous AND-OR list is executed shall
> initially be assigned to an open file description that behaves as if
> /dev/null had been opened for reading only. This initial assignment
> shall be overridden by any explicit redirection of standard input
> within the AND-OR list.

    With emphasis on the last sentence.

You write that dash does ultimately interpret this correctly but applies
it too late, after fd 0 is already /dev/null.

Perhaps because this is not merely a no-op (as 0<&0 is) and that dash does
attempt to do the right thing (too late), it suggests maybe dash should
change behaviour.

However you're right about portable shell scripts. I have to accept the
minimal interpretation and your solution is very reasonable, perhaps even
more explicit as well.

Many thanks for your explanation.

      reply	other threads:[~2026-02-10 10:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-10  1:11 Surprising behaviour when reading from a named pipe and standard input Earnestly
2026-02-10  2:00 ` Harald van Dijk
2026-02-10 10:24   ` Earnestly [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aYsHRFz5kAWkcLSb@teapot \
    --to=zibeon@gmail.com \
    --cc=dash@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.