Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read built-in #327

Merged
merged 9 commits into from
Dec 15, 2023
Merged

Read built-in #327

merged 9 commits into from
Dec 15, 2023

Conversation

magicant
Copy link
Owner

@magicant magicant commented Dec 8, 2023

Summary by CodeRabbit

  • New Features

    • Introduced a new read built-in command for reading input and assigning it to variables.
    • Added detailed documentation for the read command, including usage, options, and examples.
    • Implemented error handling for reading from standard input and processing input text.
    • Added new test cases to cover various scenarios for the read command.
  • Bug Fixes

    • Improved error messages for read-only variable assignments.
    • Enhanced input handling to support line continuation and backslash processing.
  • Documentation

    • Updated documentation to reflect new features and usage patterns of the read built-in.
  • Tests

    • Added a new scripted test for the read built-in to ensure correct behavior.
  • Chores

    • Added license headers to source files where missing.

@magicant magicant self-assigned this Dec 8, 2023
Copy link

coderabbitai bot commented Dec 8, 2023

Walkthrough

The yash shell has been updated with a new read built-in module, enhancing input reading and variable assignment capabilities. This includes parsing command line arguments, handling standard input with error management, and assigning input to shell variables with field splitting. The changes are comprehensive, touching on documentation, error handling, and testing to ensure robust functionality.

Changes

File Path Summary
yash-builtin/src/lib.rs
yash-builtin/src/read.rs
yash-builtin/src/read/prompt.rs
Added read module to public modules and built-in constants. Introduced read built-in with documentation, main async function, and license header.
yash-builtin/src/read/assigning.rs
yash-builtin/src/read/input.rs
Updated assignment logic, added functions for error messages, single field assignment, enhanced input reading with error handling and character processing functions.
yash-builtin/src/read/syntax.rs
yash-builtin/src/typeset.rs
New file for parsing command line arguments with error handling. Modified MessageBase trait implementations for error types.
yash-semantics/src/expansion/split/ifs.rs
yash-semantics/src/expansion/split/ranges.rs
Added classify_attr method for character classification. Integrated classify logic into Ranges iterator.
yash/tests/scripted_test.rs
yash/tests/scripted_test/read-p.sh
Added read_builtin test function. Test script for read built-in with various test cases.

🐇✨
In the shell where commands are spun,
A new read built-in has begun.
With input parsed and variables set,
Yash's new feature is the best yet! 🎉
🐇✨

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@magicant magicant added the enhancement New feature or request label Dec 8, 2023
@magicant magicant force-pushed the read-builtin branch 2 times, most recently from 323591e to eb6940f Compare December 10, 2023 16:35
When there are more fields than variables, the last variable receives
all remaining fields, including the field separators, but not trailing
whitespace separators. This is the behavior required by POSIX.
@magicant magicant force-pushed the read-builtin branch 2 times, most recently from 7a168e0 to 9708296 Compare December 13, 2023 16:11
@magicant magicant marked this pull request as ready for review December 13, 2023 16:12
@magicant magicant added this to the POSIX 2018 scripting milestone Dec 13, 2023
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f7f02ab and 6bde00d.
Files selected for processing (11)
  • yash-builtin/src/lib.rs (3 hunks)
  • yash-builtin/src/read.rs (1 hunks)
  • yash-builtin/src/read/assigning.rs (1 hunks)
  • yash-builtin/src/read/input.rs (1 hunks)
  • yash-builtin/src/read/prompt.rs (1 hunks)
  • yash-builtin/src/read/syntax.rs (1 hunks)
  • yash-builtin/src/typeset.rs (4 hunks)
  • yash-semantics/src/expansion/split/ifs.rs (2 hunks)
  • yash-semantics/src/expansion/split/ranges.rs (3 hunks)
  • yash/tests/scripted_test.rs (1 hunks)
  • yash/tests/scripted_test/read-p.sh (1 hunks)
Files skipped from review due to trivial changes (3)
  • yash-builtin/src/lib.rs
  • yash-builtin/src/read/prompt.rs
  • yash/tests/scripted_test/read-p.sh
Files skipped from review as they are similar to previous changes (5)
  • yash-builtin/src/read.rs
  • yash-builtin/src/read/syntax.rs
  • yash-builtin/src/typeset.rs
  • yash-semantics/src/expansion/split/ifs.rs
  • yash/tests/scripted_test.rs
Additional comments: 2
yash-semantics/src/expansion/split/ranges.rs (2)
  • 73-79: The integration of the classify logic into the next method of the Ranges iterator appears to be correctly implemented by using self.ifs.classify_attr to classify characters.

  • 138-144: The tests in the ranges.rs module seem to be well-structured and designed to cover various scenarios for the new Ranges iterator logic.

yash-builtin/src/read/assigning.rs Show resolved Hide resolved
yash-builtin/src/read/assigning.rs Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6bde00d and e985b7c.
Files selected for processing (1)
  • yash/tests/scripted_test/redir-p.sh (1 hunks)
Files skipped from review due to trivial changes (1)
  • yash/tests/scripted_test/redir-p.sh

@magicant magicant merged commit 2b94454 into master Dec 15, 2023
5 checks passed
@magicant magicant deleted the read-builtin branch December 15, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant