Skip to content

[bug] read -n N -t T ignores -n when producer is bare echo builtin (reads whole line) #1209

Closed

Description

@caomengxuan666
echo "hello" | { read -n 2 -t 5 c; echo "c=[$c]"; }

GNU bash 5.3.20: c=[he] (exactly 2 chars).
niu: c=[hello] (whole line — -n ignored).

Scoping (all confirmed on both shells): printf "hello\n" | { read -n 2 -t 5 c; } agrees ([he]); command echo "hello" | ... agrees; echo | cat | { read -n 2 -t 5 c; } agrees; echo "hello" | { read -n 2 c; } (no -t) agrees; read -N 2 -t 5 agrees. Only bare-echo (fastpath/inline builtin producer) + -n + -t together trigger it — same fastpath-channel family as #1062 (closed/fixed), but -N works while -n does not, so the timed -n path mishandles that channel.

Env: niubash 1.4.4 / rubash engine (git 1b14a3d), GNU bash 5.3.20 aarch64-linux-android (Termux) as oracle. Dup-check: searched issues for read -n -t — no match.

Activity

  1. added
    bug
    gnu-baseline
    P2-medium
    area:read
    on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-mediumarea:readbuggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions