Skip to content

fix(interpreter): redirection errors read like bash - #2611

Merged
chaliy merged 1 commit into
mainfrom
claude/redirect-error-wording
Oct 8, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/redirect-error-wording

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

A redirection that cannot be opened now reports the way bash does:

  • the diagnostic carries the line the redirect is on
  • the in-memory backend's is a directory is capitalized to the strerror text bash prints
  • a target written with a trailing slash is a directory, so echo x > nodir/ fails instead of creating a file named nodir

Why

A script that redirects into a path it did not create could not tell which
redirect failed, and the trailing-slash case failed silently in the worst
direction: bashkit created a file where the script meant a directory, so
later reads found data in a place bash would have left empty.

Before / After

echo a > f.txt
set -o noclobber
echo b > f.txt     # line 3
set +o noclobber
mkdir d
echo x > d         # line 6
echo y > nodir/    # line 7
line bash 5.2 bashkit before bashkit after
3 line 3: f.txt: cannot overwrite existing file bash: f.txt: cannot overwrite existing file bash: line 3: f.txt: cannot overwrite existing file
6 line 6: d: Is a directory bash: d: is a directory bash: line 6: d: Is a directory
7 line 7: nodir/: Is a directory, status 1 (no error; created a file nodir) bash: line 7: nodir/: Is a directory, status 1

bash names the running script where bashkit says bash:; the interpreter does
not track a script path, which is a separate known gap.

Risk

Low, but the message text is user-visible. Three existing tests asserted the
old unprefixed form and were updated. The fuzz leak detector's template match
keys on the bash: prefix and the reason suffix, both unchanged, so it still
recognizes these lines as shell echoes rather than internal leaks.

Checklist

  • cargo test -p bashkit --lib (2859 passed)
  • cargo test -p bashkit --test integration (1356 passed)
  • bash_comparison differential tests against real bash
  • cargo clippy -p bashkit --all-targets -- -D warnings
  • cargo fmt --all --check
  • cargo test -p bashkit-cli (56 passed)
  • just check-okf, just check-doc-links
  • Stack probe: 1992 KB, inside the two-MiB TM-DOS-020 budget
  • Knowledge updated (log.md)

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

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)
🔵 In progress
View logs
bashkit a9372b2 Oct 07 2026, 11:14 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 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 Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 04592e0 Commit Preview URL

Branch Preview URL
Oct 08 2026, 02:07 AM

Three gaps in what a failed redirect prints. The diagnostic had no line
number, so a script could not tell which redirect failed. The in-memory
backend's lowercase "is a directory" reached stderr instead of the
strerror text bash prints. And a target written with a trailing slash
created a file under the stripped name instead of failing, so
`echo x > nodir/` silently made a file called `nodir`.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy
chaliy force-pushed the claude/redirect-error-wording branch from a9372b2 to 04592e0 Compare October 8, 2026 02:06
@chaliy
chaliy merged commit ce8d0bd into main Oct 8, 2026
46 checks passed
@chaliy
chaliy deleted the claude/redirect-error-wording branch October 8, 2026 02:26
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.

1 participant