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

Various fixes #364

Merged
merged 8 commits into from
Apr 27, 2024
Merged

Various fixes #364

merged 8 commits into from
Apr 27, 2024

Conversation

magicant
Copy link
Owner

@magicant magicant commented Apr 27, 2024

Addresses the remaining failing scripted tests tracked in #336

Summary by CodeRabbit

  • New Features

    • Added new test functions and scripts to enhance signal trapping and error handling in tests.
    • Introduced permission checks in the file system for enhanced security.
    • Added new glob pattern handling features for more flexible file operations.
  • Bug Fixes

    • Removed outdated TODO comments indicating broken functionality in scripts.
    • Adjusted error message handling in trap tests for clarity and accuracy.
    • Updated file access functionality to handle permissions more precisely.
  • Refactor

    • Simplified async closures in subshell implementations for cleaner code.
    • Streamlined function signatures and control flow in command execution modules.
    • Removed unnecessary async constructs and simplified control flows across various modules.
  • Documentation

    • Updated CHANGELOGs and public entity declarations to reflect new behaviors and functionalities.

The test cases were disabled due to a bug, which was fixed in commit
3662079.
When a trap action is interrupted by a shell error, the exit status of
the trap action should be propagated to the calling context. This is
necessary to ensure that the exit status of the shell reflects the
error.
This commit applies the same fix as in commit 5e82a55 to the EXIT trap.
If the EXIT trap is interrupted by a shell error, the exit status of the
shell error is propagated to the calling context, which means that the
exit status of the shell error overrides the exit status of the shell.

The `run_trap` function is refactored to be used by both the EXIT and
signal traps. The `run_trap` function now takes a `Condition` argument
to specify the type of the trap, which is no longer limited to signals.
This commit refactors the closure parameter of Subshell::new to return
a Future that resolves to () instead of Result. The Subshell
implementation no longer calls Env::apply_result on the result of the
closure. Instead, Env::apply_result must be called explicitly in the
closure, if necessary.

This commit is a preparation for the upcoming fix for the issue that
the EXIT trap is not run in subshells. The EXIT trap should be run after
Env::apply_result is called in the closure, which cannot be implemented
in the yash-env crate as trap execution depends on the yash-semantics
crate.
Every subshell that may run the trap built-in should run the EXIT trap
on termination. This includes:

- Subshells created by command substitution
- Subshells created by asynchronous and-or lists
- Subshells created by job-controlled pipelines

This commit adds a call to `run_exit_trap` in the appropriate places.
@magicant magicant added the bug Something isn't working label Apr 27, 2024
@magicant magicant added this to the POSIX 2018 scripting milestone Apr 27, 2024
@magicant magicant self-assigned this Apr 27, 2024
Copy link

coderabbitai bot commented Apr 27, 2024

Walkthrough

This comprehensive update streamlines and refines the Yash project's codebase across multiple modules. Changes focus on simplifying asynchronous operations, refining error handling, updating test scripts, and enhancing functionality related to file system permissions and signal trapping. The modifications aim to boost the system's robustness and prepare it for a feature-complete beta release.

Changes

File Path Change Summary
yash-builtin/src/fg.rs
yash-builtin/src/wait/core.rs
yash-env/src/lib.rs
yash-semantics/src/command/compound_command/subshell.rs
Simplified async closures and removed unnecessary Continue(()) control flows.
yash-cli/tests/scripted_test.rs
yash-cli/tests/scripted_test/*.sh
Added new tests and removed outdated TODO comments.
yash-env/CHANGELOG.md
yash-env/src/...
yash-semantics/CHANGELOG.md
Updated function behaviors and error handling, especially related to file system access and traps.
yash-semantics/src/expansion/glob.rs
yash-semantics/src/trap/exit.rs
yash-semantics/src/trap/signal.rs
Enhanced glob pattern handling and refactored trap functionality.

Possibly related issues

Poem

🐰✨ A Poem by CodeRabbit ✨🐰

In the world of code, where logic threads,
A rabbit hopped, refining the Yash beds.
With a flick of a tail, errors swept away,
New tests in place, for a brighter day.
Through files and functions, it danced with glee,
"To a better beta, follow me!" 🌟🎉


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between b9e09e9 and 8dd9d2e.
Files selected for processing (23)
  • yash-builtin/src/fg.rs (7 hunks)
  • yash-builtin/src/wait/core.rs (1 hunks)
  • yash-cli/tests/scripted_test.rs (1 hunks)
  • yash-cli/tests/scripted_test/path-p.sh (1 hunks)
  • yash-cli/tests/scripted_test/quote-p.sh (1 hunks)
  • yash-cli/tests/scripted_test/redir-p.sh (2 hunks)
  • yash-cli/tests/scripted_test/trap-p.sh (2 hunks)
  • yash-cli/tests/scripted_test/trap2-y.sh (1 hunks)
  • yash-env/CHANGELOG.md (1 hunks)
  • yash-env/src/lib.rs (4 hunks)
  • yash-env/src/subshell.rs (23 hunks)
  • yash-env/src/system/virtual/file_system.rs (2 hunks)
  • yash-semantics/CHANGELOG.md (2 hunks)
  • yash-semantics/src/command/compound_command/subshell.rs (3 hunks)
  • yash-semantics/src/command/item.rs (2 hunks)
  • yash-semantics/src/command/pipeline.rs (3 hunks)
  • yash-semantics/src/command/simple_command/absent.rs (1 hunks)
  • yash-semantics/src/command/simple_command/external.rs (1 hunks)
  • yash-semantics/src/expansion/glob.rs (8 hunks)
  • yash-semantics/src/expansion/initial/command_subst.rs (2 hunks)
  • yash-semantics/src/trap.rs (1 hunks)
  • yash-semantics/src/trap/exit.rs (3 hunks)
  • yash-semantics/src/trap/signal.rs (6 hunks)
Files skipped from review due to trivial changes (2)
  • yash-builtin/src/fg.rs
  • yash-env/src/lib.rs
Additional Context Used
LanguageTool (30)
yash-env/CHANGELOG.md (10)

Near line 3: Possible spelling mistake found.
Context: # Changelog All notable changes to yash-env will be documented in this file. The ...


Near line 5: Only proper nouns start with an uppercase character (there are exceptions for headlines).
Context: ... in this file. The format is based on [Keep a Changelog](https://keepachangelog.com...


Near line 16: This sentence does not start with an uppercase letter.
Context: ...d - system::virtual::FileSystem::get now fails with EACCES when search permi...


Near line 16: Possible spelling mistake found.
Context: ...irtual::FileSystem::getnow fails withEACCES` when search permission is denied for...


Near line 18: Do you wish to insert an arrow?
Context: ...straint for subshell::Subshell is now `F: for<'a> FnOnce(&'a mut Env, Option) -> Pin<Box<dyn Future<Output = ()> + 'a>> ...


Near line 19: Possible typo: you repeated a whitespace
Context: ... Future<Output = ()> + 'a>> + 'static. The Output` type of the returned future...


Near line 29: This sentence does not start with an uppercase letter.
Context: ...### Fixed - RealSystem::open_tmpfile no longer returns a file descriptor with t...


Near line 29: Possible spelling mistake found.
Context: ...nger returns a file descriptor with the O_CLOEXEC flag set. ## [0.1.0] - 2024-04-13 ##...


Near line 32: Unpaired symbol: ‘[’ seems to be missing
Context: ...h the O_CLOEXEC flag set. ## [0.1.0] - 2024-04-13 ### Added - Initial impl...


Near line 36: Possible spelling mistake found.
Context: ... Added - Initial implementation of the yash-env crate [0.1.0]: https://github.com/mag...

yash-semantics/CHANGELOG.md (20)

Near line 3: Possible spelling mistake found.
Context: # Changelog All notable changes to yash-semantics will be documented in this file. The ...


Near line 5: Only proper nouns start with an uppercase character (there are exceptions for headlines).
Context: ... in this file. The format is based on [Keep a Changelog](https://keepachangelog.com...


Near line 12: Possible spelling mistake found.
Context: ...nreleased ### Added - Support for the ErrExit shell option in multi-command pipeline...


Near line 18: This sentence does not start with an uppercase letter.
Context: ...enamed to Vacancy. - EmptyError was renamed to VacantError. - `EmptyE...


Near line 18: Possible spelling mistake found.
Context: ...ncy. - EmptyErrorwas renamed toVacantError. - EmptyError::state` was renamed...


Near line 19: This sentence does not start with an uppercase letter.
Context: ...VacantError. - EmptyError::statewas renamed toVacantError::vacancy. - e...


Near line 19: Possible spelling mistake found.
Context: ... - EmptyError::state was renamed to VacantError::vacancy. - `expansion::ErrorCause::Em...


Near line 20: This sentence does not start with an uppercase letter.
Context: ...expansion::ErrorCause::EmptyExpansion was renamed to `expansion::ErrorCause::Vaca...


Near line 20: Possible spelling mistake found.
Context: ...orCause::EmptyExpansionwas renamed toexpansion::ErrorCause::VacantExpansion. - <expansion::Error...


Near line 21: This sentence does not start with an uppercase letter.
Context: ...sion::Error as handle::Handle>::handlenow returnsDivert::Exit instead ofDi...


Near line 22: Possible spelling mistake found.
Context: ...instead of Divert::Interrupt when the ErrExit shell option is applicable. - `expansi...


Near line 23: This sentence does not start with an uppercase letter.
Context: ...s applicable. - expansion::glob::glob no longer requires search permission for t...


Near line 24: Possible spelling mistake found.
Context: ... for the parent directory of the last pathname component in the pattern when the last ...


Near line 31: This sentence does not start with an uppercase letter.
Context: ...tatus. - <TextUnit as Expand>::expand now correctly expands an unset parameter wi...


Near line 32: Did you mean “she'll”?
Context: ... empty string regardless of the Unset shell option. Previously, it would expand t...


Near line 36: This sentence does not start with an uppercase letter.
Context: ...empty string. - expansion::glob::glob now handles backslash escapes in glob patte...


Near line 38: Loose punctuation mark.
Context: .... - trap::run_traps_for_caught_signals, trap::run_trap_if_caught, and `trap...


Near line 41: This sentence does not start with an uppercase letter.
Context: ...:Interrupt(_). - trap::run_exit_trap` is now called on the exit of a subshell th...


Near line 45: Unpaired symbol: ‘[’ seems to be missing
Context: ... a job-controlled pipeline. ## [0.1.0] - 2024-04-13 ### Added - Initial impl...


Near line 49: Possible spelling mistake found.
Context: ... Added - Initial implementation of the yash-semantics crate [0.1.0]: https://github.com/mag...

AST-based Instructions (2)
yash-cli/tests/scripted_test.rs (2)

[warning] 54-56: Found use of unsafe code. Unsafe code should be avoided whenever possible. Instead, prefer safe code and use unsafe code only when necessary.
Context: unsafe {
command.pre_exec(pre_exec);
}
Note: [CWE-242]: Use of Inherently Dangerous Function [REFERENCES]
- https://doc.rust-lang.org/std/keyword.unsafe.html


[warning] 73-73: Found use of unsafe code. Unsafe code should be avoided whenever possible. Instead, prefer safe code and use unsafe code only when necessary.
Context: unsafe { run_with_preexec(name, || Ok(())) }
Note: [CWE-242]: Use of Inherently Dangerous Function [REFERENCES]
- https://doc.rust-lang.org/std/keyword.unsafe.html

ShellCheck (184)
yash-cli/tests/scripted_test/path-p.sh (19)

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


[warning] 3-3: posix appears unused. Verify use (or export if used externally).


[error] 6-6: Multiple redirections compete for stdout. Use cat, tee, or pass filenames instead.


[warning] 6-6: This redirection doesn't have a command. Move to its command (or use 'true' as no-op).


[error] 6-6: Multiple redirections compete for stdout. Use cat, tee, or pass filenames instead.


[error] 6-6: Multiple redirections compete for stdout. Use cat, tee, or pass filenames instead.


[warning] 25-25: This is a glob used as a command name. Was it supposed to be in ${..}, array, or is it missing quoting?


[warning] 31-31: This is a glob used as a command name. Was it supposed to be in ${..}, array, or is it missing quoting?


[warning] 38-38: This is a glob used as a command name. Was it supposed to be in ${..}, array, or is it missing quoting?


[warning] 39-39: This is a glob used as a command name. Was it supposed to be in ${..}, array, or is it missing quoting?


[warning] 45-45: This is a glob used as a command name. Was it supposed to be in ${..}, array, or is it missing quoting?


[warning] 51-51: This is a glob used as a command name. Was it supposed to be in ${..}, array, or is it missing quoting?


[warning] 57-57: This is a glob used as a command name. Was it supposed to be in ${..}, array, or is it missing quoting?


[warning] 62-62: This redirection doesn't have a command. Move to its command (or use 'true' as no-op).


[warning] 63-63: skip appears unused. Verify use (or export if used externally).


[warning] 76-76: This is a glob used as a command name. Was it supposed to be in ${..}, array, or is it missing quoting?


[warning] 77-77: This is a glob used as a command name. Was it supposed to be in ${..}, array, or is it missing quoting?


[warning] 89-89: This is a glob used as a command name. Was it supposed to be in ${..}, array, or is it missing quoting?


[error] 107-107: This is interpreted as a command name ending with '/'. Double check syntax.

yash-cli/tests/scripted_test/quote-p.sh (3)

[error] 13-13: Couldn't parse this test expression. Fix to allow more checks.


[error] 13-13: You are missing a required space here.


[error] 13-13: Expected test to end here (don't wrap commands in []/[[]]). Fix any mentioned problems and try again.

yash-cli/tests/scripted_test/redir-p.sh (4)

[info] 435-435: The mentioned syntax error was in this simple command.


[error] 435-435: Couldn't parse this here document. Fix to allow more checks.


[error] 435-435: Couldn't find end token `E'N'D' in the here document.


[error] 566-566: Here document was not correctly terminated. Fix any mentioned problems and try again.

yash-cli/tests/scripted_test/trap-p.sh (156)

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


[warning] 3-3: posix appears unused. Verify use (or export if used externally).


[info] 93-93: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 94-94: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 95-95: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 97-97: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 98-98: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 98-98: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 99-99: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 100-100: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 101-101: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 103-103: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 104-104: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 104-104: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 105-105: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 106-106: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 107-107: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 109-109: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 110-110: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 111-111: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 112-112: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 113-113: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 114-114: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 116-116: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 117-117: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 118-118: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 119-119: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 120-120: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 122-122: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 123-123: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 124-124: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 125-125: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 126-126: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 128-128: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 129-129: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 130-130: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 132-132: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 133-133: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 134-134: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 135-135: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 136-136: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 137-137: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 138-138: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 140-140: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 141-141: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 142-142: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 144-145: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 145-145: Expressions don't expand in single quotes, use double quotes for that.


[info] 146-146: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 147-147: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 148-148: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 149-149: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 151-152: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 152-152: Expressions don't expand in single quotes, use double quotes for that.


[info] 153-153: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 154-154: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 155-155: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 156-156: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 158-159: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 160-160: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 161-161: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 162-162: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 164-165: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 166-166: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 167-167: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 168-168: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 170-171: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 172-172: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 173-173: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 174-174: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 176-177: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 178-178: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 179-179: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 180-180: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 182-183: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 184-184: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 186-186: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 187-187: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 188-188: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 189-189: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 190-190: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 191-191: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 192-192: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 193-193: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 194-194: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 195-195: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 197-197: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 198-198: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 199-202: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 200-200: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 201-201: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 203-203: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 204-204: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 205-205: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 206-206: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 208-208: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 209-209: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 210-210: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 211-211: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 211-211: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 212-212: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 213-213: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 214-214: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 215-215: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 216-216: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 217-217: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 219-219: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 220-220: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 221-221: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 222-222: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 223-223: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 224-224: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 225-225: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 226-226: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 228-228: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 229-229: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 230-230: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 231-231: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 232-232: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 234-234: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 235-235: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 235-235: This \c will be a regular 'c' in this context.


[info] 236-236: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 237-237: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 238-238: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 238-238: Not following: ./printed_trap was not specified as input (see shellcheck -x).


[info] 239-239: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 240-240: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 241-241: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 242-242: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 244-244: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 245-245: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 245-245: This \c will be a regular 'c' in this context.


[info] 246-246: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 246-246: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 247-247: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 248-248: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 249-249: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 250-250: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 251-251: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 252-252: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 254-254: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 255-255: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 257-257: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 258-258: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 259-259: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 260-260: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 261-261: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 262-262: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 263-263: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 265-265: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 266-266: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 266-266: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 267-267: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 268-268: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


[info] 269-269: Command appears to be unreachable. Check usage (or ignore if invoked indirectly).

yash-cli/tests/scripted_test/trap2-y.sh (2)

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


[warning] 4-4: Piping to 'trap', a command that doesn't read stdin. Wrong command or missing xargs?

Learnings (2)
yash-cli/tests/scripted_test/trap2-y.sh (3)
User: magicant
PR: magicant/yash-rs#339
File: yash/tests/scripted_test/fg-p.sh:68-70
Timestamp: 2024-01-08T15:45:35.594Z
Learning: The `run-test.sh` script in the `yash` repository uses options `-d` to require non-empty standard error output and `-e n` to require a non-zero exit status in test cases. This information is crucial for understanding how test cases are structured and validated within this codebase.
User: magicant
PR: magicant/yash-rs#339
File: yash/tests/scripted_test/fg-p.sh:18-21
Timestamp: 2024-01-08T15:45:36.866Z
Learning: The `run-test.sh` script in the `yash` repository uses the `-d` option to require non-empty output to standard error and the `-e n` option to require a non-zero exit status in test cases.
User: magicant
PR: magicant/yash-rs#339
File: yash/tests/scripted_test/bg-p.sh:97-103
Timestamp: 2024-01-08T15:45:07.471Z
Learning: The user has clarified that the `-d` option in the `yash/tests/scripted_test/run-test.sh` script requires a non-empty output to the standard error, and the `-e n` option requires a non-zero exit status. This information is crucial for understanding how test cases are asserted within the `yash` shell's testing framework.
yash-cli/tests/scripted_test/redir-p.sh (3)
User: magicant
PR: magicant/yash-rs#319
File: yash/tests/scripted_test/typeset-y.sh:52-58
Timestamp: 2023-11-20T15:52:00.741Z
Learning: The `export` and `readonly` built-ins are still used in the `yash` codebase, and care should be taken to consider the broader context of the code when reviewing diffs and making suggestions.
User: magicant
PR: magicant/yash-rs#320
File: yash/tests/scripted_test/readonly-p.sh:0-0
Timestamp: 2023-11-23T12:47:34.276Z
Learning: The test case for verifying the behavior when attempting to reassign a read-only variable in `yash/tests/scripted_test/readonly-p.sh` has been updated to check for an error or exit status.
User: magicant
PR: magicant/yash-rs#319
File: yash/tests/scripted_test/typeset-y.sh:146-152
Timestamp: 2023-11-20T15:52:03.828Z
Learning: The `typeset -x` command is no longer relevant in the context of the `yash` shell's test cases due to the introduction of the `export` built-in. However, the `export` and `readonly` built-ins are still used in other parts of the code not shown in the diff provided.
Additional comments not posted (23)
yash-semantics/CHANGELOG.md (1)

23-25: Clarify the change regarding search permissions for glob patterns to ensure it is understood in context.
[CLARIFY]

yash-semantics/src/trap.rs (1)

63-95: Ensure proper handling of the trap's exit status and its propagation. Verify that the logic correctly restores or updates the exit status based on the trap's outcome.

yash-cli/tests/scripted_test/trap-p.sh (1)

122-122: Verify that the command after the fatal error trap is indeed unreachable. If it is intended to be unreachable, consider removing or commenting it out for clarity.

yash-semantics/src/trap/exit.rs (1)

Line range hint 19-44: Ensure that the EXIT trap handling correctly restores the exit status or applies a new one based on the trap's termination condition.

yash-cli/tests/scripted_test.rs (1)

380-383: LGTM! The addition of trap_ex_2 enhances test coverage for trap functionalities.

yash-builtin/src/wait/core.rs (2)

131-131: Simplified async closure in Subshell::new enhances readability and reduces unnecessary complexity.


131-131: The test finished_job effectively verifies the immediate return behavior of wait_for_any_job_or_trap when a job finishes.

yash-semantics/src/expansion/initial/command_subst.rs (2)

25-25: Addition of run_exit_trap usage in command substitution ensures proper trap handling.


59-61: Proper error handling in subshell_body function enhances robustness by applying the result of error handling.

yash-semantics/src/command/simple_command/absent.rs (1)

57-60: Enhanced error handling in redirections within execute_absent_target function improves reliability and user feedback.

yash-semantics/src/command/compound_command/subshell.rs (1)

67-67: Implementation of subshell_main function correctly handles command execution and trap application in a subshell.

yash-semantics/src/trap/signal.rs (2)

48-48: Confirm the correct handling of asynchronous trap execution.

Ensure that the asynchronous execution of traps is handled correctly and does not lead to any race conditions or deadlocks.


89-89: Check for potential issues with running multiple traps concurrently.

Verify that the logic to handle multiple concurrent traps is robust and does not allow for any unintended behavior or errors.

yash-semantics/src/command/item.rs (2)

19-19: Confirm the correct usage of run_exit_trap.

Ensure that the run_exit_trap function is used appropriately and integrates well with the rest of the command execution flow.


104-111: Review the handling of standard input in asynchronous commands.

Verify that the handling of standard input redirection in asynchronous commands is correct and does not lead to any unexpected behavior.

yash-env/src/system/virtual/file_system.rs (1)

153-156: Added permission check for search access.

Ensure that this error handling is consistent with other parts of the system.

yash-semantics/src/command/simple_command/external.rs (1)

110-110: Simplified creation of asynchronous closures.

Verify that the behavior of the function remains unchanged after this simplification.

yash-semantics/src/expansion/glob.rs (1)

120-142: Handling of new pattern syntax implemented.

Verify that this new pattern handling integrates well with the rest of the system.

yash-semantics/src/command/pipeline.rs (4)

137-141: Ensure proper error handling and exit status management in asynchronous closures.


183-189: Optimize the handling of pipes in asynchronous closures to ensure efficient resource management.


137-141: Review the use of asynchronous closures to ensure they are used effectively and efficiently.


183-189: Ensure efficient error handling and resource management in pipe connections.

yash-env/src/subshell.rs (1)

196-196: Ensure that the subshell correctly handles job control and signal blocking.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 4

Out of diff range and nitpick comments (6)
yash-cli/tests/scripted_test/path-p.sh (2)

Line range hint 1-1: Add a shebang line to specify the shell interpreter.

+ #!/bin/sh

Line range hint 6-6: Multiple redirections compete for stdout. Consider using 'cat', 'tee', or specifying filenames directly.

- >foo/dir/file >foo/no_read_dir/file >foo/no_search_dir/file
+ echo "" | tee foo/dir/file foo/no_read_dir/file foo/no_search_dir/file > /dev/null
yash-cli/tests/scripted_test/trap-p.sh (1)

Line range hint 1-1: Add a shebang line to specify the shell interpreter.

+ #!/bin/sh
yash-cli/tests/scripted_test/quote-p.sh (1)

Line range hint 13-13: Syntax error in test expression. Ensure proper formatting to allow further checks.

- test_oE 'backslash (not preceding newline)'
+ test_oE 'backslash (not preceding newline)' {
yash-cli/tests/scripted_test/redir-p.sh (2)

Line range hint 435-435: Fix the syntax error in the here-document.

- cat <<E'N'D &&
+ cat <<'END' &&

Line range hint 566-566: Ensure the here-document is correctly terminated.

- cat << -END
+ cat <<-'END'

yash-semantics/src/trap/signal.rs Show resolved Hide resolved
yash-cli/tests/scripted_test/trap2-y.sh Show resolved Hide resolved
yash-cli/tests/scripted_test/trap2-y.sh Show resolved Hide resolved
yash-env/CHANGELOG.md Show resolved Hide resolved
@magicant magicant merged commit 807295a into master Apr 27, 2024
6 checks passed
@magicant magicant deleted the fixes branch April 27, 2024 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant