Skip to content

feat(read): fill out more of read builtin - #914

Merged
reubeno merged 9 commits into
mainfrom
read-builtin
Jan 8, 2026
Merged

reubeno merged 9 commits into
mainfrom
read-builtin

Conversation

@reubeno

@reubeno reubeno commented Jan 8, 2026

Copy link
Copy Markdown
Owner

No description provided.

@github-actions

github-actions Bot commented Jan 8, 2026 •

Copy link
Copy Markdown

Public API changes for crate: brush-core

Added items

+pub fn brush_core::openfiles::OpenFile::try_borrow_as_fd(&self) -> core::result::Result<std::os::fd::owned::BorrowedFd<'_>, brush_core::error::Error>
+pub mod brush_core::sys::poll
+pub fn brush_core::sys::poll::poll_for_input(file: &brush_core::openfiles::OpenFile, timeout: core::time::Duration) -> std::io::error::Result<bool>

Performance Benchmark Report

Benchmark name Baseline (μs) Test/PR (μs) Delta (μs) Delta %
clone_shell_object 16.61 μs 17.05 μs 0.43 μs 🟠 +2.61%
eval_arithmetic 0.15 μs 0.15 μs -0.00 μs ⚪ Unchanged
expand_one_string 1.59 μs 1.57 μs -0.02 μs ⚪ Unchanged
for_loop 23.40 μs 22.64 μs -0.76 μs 🟢 -3.25%
function_call 2.56 μs 2.23 μs -0.33 μs 🟢 -13.03%
instantiate_shell 51.14 μs 51.02 μs -0.11 μs ⚪ Unchanged
instantiate_shell_with_init_scripts 25356.03 μs 24427.96 μs -928.07 μs 🟢 -3.66%
parse_bash_completion 2063.12 μs 2038.47 μs -24.65 μs ⚪ Unchanged
parse_sample_script 2.06 μs 1.99 μs -0.06 μs 🟢 -3.11%
run_echo_builtin_command 15.66 μs 15.73 μs 0.06 μs ⚪ Unchanged
tokenize_sample_script 3.37 μs 3.35 μs -0.01 μs ⚪ Unchanged

Code Coverage Report: Only Changed Files listed

Package Base Coverage New Coverage Difference
brush-builtins/src/read.rs 🟢 85.78% 🟢 91.61% 🟢 5.83%
brush-core/src/sys/unix/poll.rs 🔴 0% 🟢 85% 🟢 85%
Overall Coverage 🟢 73.59% 🟢 73.85% 🟢 0.26%

Minimum allowed coverage is 70%, this run produced 73.85%

Test Summary: bash-completion test suite

Outcome Count Percentage
✅ Pass 1559 73.92
❗️ Error 17 0.81
❌ Fail 179 8.49
⏩ Skip 339 16.07
❎ Expected Fail 13 0.62
✔️ Unexpected Pass 2 0.09
📊 Total 2109 100.00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR significantly expands the read builtin implementation to support timeout functionality (-t option), raw mode (-r option), and fixes several IFS (Internal Field Separator) splitting edge cases. The implementation adds comprehensive polling support for Unix platforms with appropriate stubs for Windows and WASM.

Key changes:

  • Implements timeout support for read -t with fractional second precision
  • Implements raw mode (-r) to disable backslash escape processing
  • Fixes IFS splitting logic to correctly handle consecutive delimiters and preserve original delimiters in remainder fields
  • Adds 150+ new integration test cases covering edge cases

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
brush-shell/tests/cases/builtins/read.yaml Removes known_failure marker from trailing delimiter test; adds 150+ comprehensive test cases for timeout, raw mode, -N vs -n options, exit codes, IFS edge cases, and backslash processing
brush-core/src/sys/unix/poll.rs New file implementing file descriptor polling with timeout support using nix's poll interface, handles EINTR correctly
brush-core/src/sys/stubs/poll.rs New stub implementation returning "Unsupported" error for platforms without poll support
brush-core/src/sys/unix.rs Exports new poll module
brush-core/src/sys/windows.rs Exports stubbed poll module for Windows
brush-core/src/sys/wasm.rs Exports stubbed poll module for WASM
brush-core/src/sys/stubs.rs Adds poll module to stubs
brush-core/src/sys.rs Re-exports platform-specific poll module
brush-core/src/openfiles.rs Changes try_borrow_as_fd visibility from pub(crate) to pub to support poll module
brush-core/Cargo.toml Adds "poll" feature to nix dependency
brush-builtins/src/read.rs Major refactoring: implements timeout logic, raw mode, refactors IFS splitting with correct edge case handling, adds helper structs (InputReader, LineReaderConfig), adds comprehensive documentation and 120+ lines of unit tests

Comment thread brush-builtins/src/read.rs Resolved
Comment thread brush-builtins/src/read.rs Resolved
Comment thread brush-core/src/sys/unix/poll.rs Resolved
@github-actions

github-actions Bot commented Jan 8, 2026 •

Copy link
Copy Markdown

Test Results

    3 files     29 suites   12m 18s ⏱️
1 587 tests 1 587 ✅ 0 💤 0 ❌
4 737 runs  4 737 ✅ 0 💤 0 ❌

Results for commit cd67518.

♻️ This comment has been updated with latest results.

@reubeno
reubeno marked this pull request as ready for review January 8, 2026 08:16
@reubeno
reubeno merged commit afe9bbd into main Jan 8, 2026
44 checks passed
@reubeno
reubeno deleted the read-builtin branch January 8, 2026 08:24
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.

2 participants