Repository navigation
fix(read): apply -n/-N quotas in the timed-read fast path - #1316
Merged
Merged
Conversation
…#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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1209
Summary
echo "hello" | { read -n 2 -t 5 c; }boundhello— the timed-read fast path (execute_timed_read_pipeline) parsed-n/-Nas skip-operands and modeled only the-tdeadline.timed_read_optionsnow carries the quota (-n/-N, separate and attached);timed_read_valueapplies it per GNUread.def:884-886—-nstops at the quota or the delimiter,-Nreads the quota exactly. EOF before the quota is an unterminated record (status 1;-Nkeeps the record raw).Before:
c=[hello]— After:c=[he](matches GNU 5.3.20 for-n,-N, EOF-partial, and-t0cases)Test plan
tests/issue1209_read_n_timed.rs(4 cases vs WSL GNU Bash 5.3.20)cargo fmtcleanGenerated with Devin