Skip to content

fix(interpreter): non-fatal input redirect for missing file#2063

Merged
chaliy merged 3 commits into
mainfrom
fix/pr-2050-input-redirect-missing-file
Jun 12, 2026
Merged

fix(interpreter): non-fatal input redirect for missing file#2063
chaliy merged 3 commits into
mainfrom
fix/pr-2050-input-redirect-missing-file

Conversation

@chaliy

@chaliy chaliy commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Closes #2050

Missing input-redirect target (cmd < /no-such-file) was propagating as Err(...) from exec(), aborting the entire script. Real bash fails the individual command with exit code 1 and a diagnostic on stderr, then continues.

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 return Ok(ExecResult) with exit code 1 instead of aborting. Regression tests assert the failed command reports $? == 1 while the overall script exit code stays 0.

…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.
Copilot AI review requested due to automatic review settings June 12, 2026 10:51
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
bashkit c081810 Jun 12 2026, 02:30 PM

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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::CommandFailure to represent non-fatal, bash-level failures.
  • Converts input-redirection read_file failures into non-fatal command failures and catches them at key execution points to return Ok(ExecResult) with exit code 1.
  • Adds integration tests to ensure missing input redirects don’t abort execution and $? is set to 1.

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.

Comment thread crates/bashkit/tests/integration/blackbox_security_tests.rs
Comment thread crates/bashkit/tests/integration/blackbox_security_tests.rs
@chaliy chaliy force-pushed the fix/pr-2050-input-redirect-missing-file branch from 9f95e12 to 87e0730 Compare June 12, 2026 14:26
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.
@chaliy chaliy merged commit 2ffa002 into main Jun 12, 2026
35 of 36 checks passed
@chaliy chaliy deleted the fix/pr-2050-input-redirect-missing-file branch June 12, 2026 14:37
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.

Input redirect from missing file aborts exec() instead of failing the command like bash

2 participants