Skip to content

fix(read): apply -n/-N quotas in the timed-read fast path - #1316

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/1209-read-n-timed
Oct 23, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/1209-read-n-timed

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Fixes #1209

Summary

  • echo "hello" | { read -n 2 -t 5 c; } bound hello — the timed-read fast path (execute_timed_read_pipeline) parsed -n/-N as skip-operands and modeled only the -t deadline.
  • timed_read_options now carries the quota (-n / -N, separate and attached); timed_read_value applies it per GNU read.def:884-886 — -n stops at the quota or the delimiter, -N reads the quota exactly. EOF before the quota is an unterminated record (status 1; -N keeps the record raw).

Before: c=[hello] — After: c=[he] (matches GNU 5.3.20 for -n, -N, EOF-partial, and -t0 cases)

Test plan

  • tests/issue1209_read_n_timed.rs (4 cases vs WSL GNU Bash 5.3.20)
  • cargo fmt clean

Generated with Devin

…#1209)

`echo hello | { read -n 2 -t 5 c; }` bound the whole line — the timed
fast path parsed -n/-N as skip-operands and modeled only the -t
deadline. GNU read.def:884-886 stops -n at the quota or the delimiter
and reads -N's quota exactly; timed_read_options now carries the quota
through and timed_read_value applies it, including the EOF-before-quota
unterminated record (status 1, -N keeps the record raw).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666
caomengxuan666 merged commit 05e5c26 into master Oct 23, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/1209-read-n-timed branch October 23, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant