Skip to content

[bug] Pipeline last stage own 2>file loses its command-not-found diagnostic entirely #1571

Closed

Description

@caomengxuan666

Summary

When the last stage of a pipeline carries its own 2>file redirection and the command is not found, the command not found diagnostic is lost entirely — it appears neither on the shell's stderr nor in the redirected file. The file is created (empty), the exit status is correct, only the diagnostic vanishes.

Found as residual R3 during the followup-a cluster work (#1551/#1552). It is not part of #1552: #1552 fixed the environmental 2>&1 binding around a pipeline; this is the last stage's own file redirection. It also reproduces on binaries predating the #1552 fix, so it is an independent pre-existing mechanism (suspected interaction between the last-stage diagnostic channel and the pipeline stage stream file routing — unadjudicated).

Reproduction (Regression seed:)

f=$(mktemp)
PATH=/nonexistent
nosuchA | nosuchB 2>"$f"
echo "PIPESTATUS=${PIPESTATUS[*]}"
echo "--- file content:"
cat "$f"

Expected (GNU bash 5.3.20)

  • stderr: bash: line 1: nosuchA: command not found
  • file content: bash: line 1: nosuchB: command not found
  • PIPESTATUS=127 127

Actual (rubash, master a4c6c2ad, also on the followup-a tree)

  • stderr: bash: line 1: nosuchA: command not found (first stage fine)
  • file content: (empty — the nosuchB diagnostic appears nowhere)
  • PIPESTATUS=127 127 (statuses correct)

The first stage's diagnostic is unaffected; only the last stage's own-2>file diagnostic is dropped.

Activity

  1. added
    bug
    gnu-baseline
    on Oct 26, 2026
  2. added a commit that references this issue on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buggnu-baseline

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions