public inbox for dash@vger.kernel.org
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Pablo Repetto <pablo.ernesto.repetto@gmail.com>
Cc: dash@vger.kernel.org
Subject: Re: bug: background jobs have their inputs bound to `/dev/null`, even in the face of explicit redirection
Date: Sun, 9 Mar 2025 17:54:52 +0800	[thread overview]
Message-ID: <Z81lbCfWHCoAipOM@gondor.apana.org.au> (raw)
In-Reply-To: <CAFKqKCrEXCkyFTx8SqOHx=LHYyKpfa6scjcrMCxA=Hoo0p9yMA@mail.gmail.com>

Pablo Repetto <pablo.ernesto.repetto@gmail.com> wrote:
>
> # the following produces no output, both are erroneous
> echo x | { cat & wait; }

This is totally expected and correct.

> echo x | { <&0 cat & wait; }

This is expected too only because you're doing 0<&0 which is
a no-op.  To get what you want to happen,  you need to save the
zero fd before dash redirects it:

echo x | { { cat <&3& } 3<&0; wait; }

> # OTHER SUPPORTING EVIDENCE
> 
> bash received a closely related bug report in 2016. Both the discussion
> on whether a pipeline into a compound command counts as explicit redirection
> and the ultimate patch applied are extremely relevant.
> 
> https://groups.google.com/g/gnu.bash.bug/c/bgTSFM8UAek

I disagree.  If you like bash's behaviour, please get the standard
changed.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      reply	other threads:[~2025-03-09  9:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-15 22:16 bug: background jobs have their inputs bound to `/dev/null`, even in the face of explicit redirection Pablo Repetto
2025-03-09  9:54 ` Herbert Xu [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=Z81lbCfWHCoAipOM@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=dash@vger.kernel.org \
    --cc=pablo.ernesto.repetto@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox