fix(interpreter): non-fatal input redirect for missing file#2063
Merged
Conversation
…t 1 instead of aborting exec() Closes #2050 Missing input-redirect target now fails the command with exit code 1 and a bash-style diagnostic on stderr, matching real bash behaviour. Execution continues with the rest of the script. Adds Error::CommandFailure for bash-level non-fatal failures; converts read_file errors in process_input_redirections and execute_exec_builtin to CommandFailure so callers can return Ok(ExecResult) instead of propagating the error.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
bashkit | c081810 | Jun 12 2026, 02:30 PM |
There was a problem hiding this comment.
Pull request overview
Adjusts the interpreter to treat missing input-redirection targets (e.g., cmd < /no-such-file) as a bash-style, non-fatal command failure (exit code 1 + stderr diagnostic) rather than aborting the entire Bash::exec() execution with an error.
Changes:
- Introduces
Error::CommandFailureto represent non-fatal, bash-level failures. - Converts input-redirection
read_filefailures into non-fatal command failures and catches them at key execution points to returnOk(ExecResult)with exit code 1. - Adds integration tests to ensure missing input redirects don’t abort execution and
$?is set to1.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/bashkit/tests/integration/blackbox_security_tests.rs | Adds regression tests for non-fatal missing input redirects (simple + compound). |
| crates/bashkit/src/tool.rs | Adds CommandFailure handling in error categorization. |
| crates/bashkit/src/interpreter/mod.rs | Converts missing input redirect file reads into non-fatal failures and catches them to continue execution. |
| crates/bashkit/src/error.rs | Adds Error::CommandFailure variant for bash-level non-fatal failures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…t redirect failure
9f95e12 to
87e0730
Compare
Cargo.toml requires the monty (python feature) dependency tree, but the checked-in lock lacked those entries, so --locked builds (the Cloudflare Workers build) failed. Regenerates the lock to match Cargo.toml.
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.
Closes #2050
Missing input-redirect target (
cmd < /no-such-file) was propagating asErr(...)fromexec(), aborting the entire script. Real bash fails the individual command with exit code 1 and a diagnostic on stderr, then continues.Adds
Error::CommandFailurefor bash-level non-fatal failures. Convertsread_fileerrors inprocess_input_redirectionsandexecute_exec_builtintoCommandFailureso callers returnOk(ExecResult)with exit code 1 instead of aborting. Regression tests assert the failed command reports$? == 1while the overall script exit code stays 0.