-
Notifications
You must be signed in to change notification settings - Fork 3
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
Show $PS2 prompt for continuation lines in the read built-in #380
Conversation
This commit extracts the `fetch_posix` function from the `print_prompt` function in `yash-prompt`. The extracted function is now public and helps to fetch the prompt string from the variable set.
WalkthroughThis update introduces enhancements across various modules for the Yash shell. Key changes include adding dependency checks for complex builds, updating built-in functionalities, refining environment detection for interactivity, and improving prompt handling. These modifications aim to align the project with POSIX 2018 requirements, optimize the code, and enhance user interaction. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant YashCLI
participant YashBuiltin
participant YashEnv
participant YashPrompt
User->>YashCLI: Enter command with read built-in
YashCLI->>YashEnv: Check if interactive (is_interactive)
YashEnv-->>YashCLI: Return interactivity status
YashCLI->>YashBuiltin: Call read function
YashBuiltin->>YashPrompt: Fetch and print prompt for continuation (fetch_posix)
YashPrompt-->>YashBuiltin: Return prompt string
YashBuiltin-->>User: Display prompt and read input
Possibly related issues
Poem
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 your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range and nitpick comments (1)
yash-env/CHANGELOG.md (1)
15-15
: Fix unordered list indentation.The unordered list indentation should be 2 spaces instead of 4 to adhere to the Markdownlint rule MD007.
- - This is a decorator of `Input` that implements the behavior of the verbose shell option. + - This is a decorator of `Input` that implements the behavior of the verbose shell option.Tools
Markdownlint
15-15: Expected: 2; Actual: 4
Unordered list indentation(MD007, ul-indent)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (10)
- check-extra.sh (1 hunks)
- yash-builtin/CHANGELOG.md (1 hunks)
- yash-builtin/Cargo.toml (2 hunks)
- yash-builtin/src/read.rs (1 hunks)
- yash-builtin/src/read/input.rs (4 hunks)
- yash-cli/CHANGELOG.md (1 hunks)
- yash-env/CHANGELOG.md (1 hunks)
- yash-env/src/lib.rs (2 hunks)
- yash-prompt/src/lib.rs (2 hunks)
- yash-prompt/src/prompter.rs (4 hunks)
Files skipped from review due to trivial changes (2)
- yash-builtin/Cargo.toml
- yash-builtin/src/read.rs
Additional context used
Learnings (3)
yash-prompt/src/lib.rs (1)
Learnt from: magicant PR: magicant/yash-rs#376 File: yash-prompt/src/lib.rs:17-19 Timestamp: 2024-07-03T03:32:18.685Z Learning: The `yash-prompt` crate provides functionalities to show a command prompt, including the `expand_posix` function and the `Prompter` struct.
yash-prompt/src/prompter.rs (1)
Learnt from: magicant PR: magicant/yash-rs#376 File: yash-prompt/src/lib.rs:17-19 Timestamp: 2024-07-03T03:32:18.685Z Learning: The `yash-prompt` crate provides functionalities to show a command prompt, including the `expand_posix` function and the `Prompter` struct.
yash-builtin/src/read/input.rs (1)
Learnt from: magicant PR: magicant/yash-rs#376 File: yash-prompt/src/lib.rs:17-19 Timestamp: 2024-07-03T03:32:18.685Z Learning: The `yash-prompt` crate provides functionalities to show a command prompt, including the `expand_posix` function and the `Prompter` struct.
Markdownlint
yash-env/CHANGELOG.md
15-15: Expected: 2; Actual: 4
Unordered list indentation(MD007, ul-indent)
Additional comments not posted (14)
yash-cli/CHANGELOG.md (1)
37-37
: Changelog entry is clear and concise.The description of the new feature for the
read
built-in is well-documented.check-extra.sh (4)
21-21
: Addition ofcargo check
command foryash-builtin
package is appropriate.The new command ensures that unnecessary dependencies are checked for the
yash-builtin
package without default features.
22-22
: Addition ofcargo check
command foryash-builtin
package withyash-semantics
feature is appropriate.The new command ensures that unnecessary dependencies are checked for the
yash-builtin
package with theyash-semantics
feature.
23-23
: Addition ofcargo check
command foryash-syntax
package is appropriate.The new command ensures that unnecessary dependencies are checked for the
yash-syntax
package without default features.
29-29
: Addition ofcargo build
command foryash-builtin
package withyash-semantics
feature is appropriate.The new command ensures that the
yash-builtin
package can be built with theyash-semantics
feature and no default features.yash-builtin/CHANGELOG.md (1)
17-17
: Changelog entry is clear and concise.The description of the new feature for the
read
built-in is well-documented.yash-prompt/src/lib.rs (2)
30-31
: Documentation offetch_posix
function is clear and concise.The description of the new function for fetching the value of a variable defined by POSIX for a prompt string is well-documented.
75-75
: Export offetch_posix
function is appropriate.The new function is now publicly accessible from the
prompter
module.yash-prompt/src/prompter.rs (2)
22-22
: Good use of constants for variable names.Using constants like
PS1
andPS2
for variable names improves maintainability and reduces the risk of errors.
63-70
: Ensure prompt expansion handles edge cases.The
print_prompt
function correctly fetches and expands the prompt string. Ensure that theexpand_posix
function handles all edge cases, such as special characters and nested expansions.yash-builtin/src/read/input.rs (3)
98-99
: Update documentation to mention theyash-prompt
feature.The documentation correctly mentions the requirement of the
yash-prompt
feature for interactive prompts.
118-118
: Ensureprint_prompt
function is called correctly.The
print_prompt
function is called when a line continuation is encountered. Ensure that it is called in all necessary scenarios.
183-211
: Good implementation of theprint_prompt
function.The
print_prompt
function is well-implemented, checking for an interactive shell and terminal input before printing the prompt.yash-env/src/lib.rs (1)
306-315
: Correct implementation ofis_interactive
method.The
is_interactive
method correctly checks theInteractive
option and the stack forFrame::Subshell
.
My plan for yash-specific prompt variable support is to add a new function `fetch_ex` that will handle the `$YASH_PS1` and `$YASH_PS2` variables. To make this clear, this commit moves the TODO comment out of the `fetch_posix` function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- yash-prompt/src/prompter.rs (4 hunks)
Files skipped from review as they are similar to previous changes (1)
- yash-prompt/src/prompter.rs
Summary by CodeRabbit
New Features
read
built-in now displays a prompt for continued lines in interactive mode.Improvements
Documentation