Skip to content

shell(touch): name --time in its unsupported option message - #39219

Open
robobun wants to merge 1 commit into
mainfrom
farm/b6983654/shell-touch-time-unsupported-message
Open

robobun wants to merge 1 commit into
mainfrom
farm/b6983654/shell-touch-time-unsupported-message

Conversation

@robobun

@robobun robobun commented Aug 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • touch --time x in the Bun shell fails with touch: unsupported option, please open a GitHub issue -- --reference=FILE, naming an option the user did not pass.
  • The --time arm of parse_long in src/runtime/shell/builtin/touch.rs:360 passes the --reference=FILE literal copied from the --reference arm above it. The same line was in the Zig version, so this is not a port regression.
  • Exit code 1 is already right; only the text is wrong.

Fix

Background

  • The shell builtins touch, mkdir, cat and cp parse their flags through the shared FlagParser trait in src/runtime/shell/interpreter.rs. A builtin returns ParseFlagResult::Unsupported(name) for an option it recognizes but does not implement, and Builtin::fail_parse formats name into the unsupported option, please open a GitHub issue -- <name> line, so the text after -- is whatever literal the builtin chose to pass, not the argv entry.
  • touch is a shell builtin on every platform (unlike cat and cp, which defer to the system binary on POSIX), so the test needs no platform gating.

The --time arm of touch's long option table reported the option as
--reference=FILE, copied from the arm above it, so `touch --time`
pointed users at an option they had not passed. Report it as --time,
like the other arms report the option that was given.

Adds a table test pinning the message for every unsupported touch
option.
@robobun

robobun commented Aug 15, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 4:07 PM PT - Aug 15th, 2026

✅ @robobun, your commit 74c75d53d49677998494ea85714857e85989a67e passed in Build #98715! 🎉


🧪   To try this PR locally:

bunx bun-pr 39219

That installs a local version of the PR into your bun-39219 executable, so you can run:

bun-39219 --bun

@robobun

robobun commented Aug 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: reproduced on bun 1.4.0 (touch --time x reports -- --reference=FILE); fixed in this PR, with test/js/bun/shell/commands/touch.test.ts failing on the released build and passing on this branch. CI is green. #39227 is stacked on this PR (it extends the same test table), so this one is meant to land first. Ready for review.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@robobun, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3e5c8a0e-d112-4162-8658-f78b40a46a33

📥 Commits

Reviewing files that changed from the base of the PR and between bcba472 and 74c75d5.

📒 Files selected for processing (2)
  • src/runtime/shell/builtin/touch.rs
  • test/js/bun/shell/commands/touch.test.ts

Comment @coderabbitai help to get the list of available commands.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — one-literal copy-paste fix in the --time match arm.

What was reviewed:

  • Confirmed fail_parse → fmt_error_arena produces exactly touch: unsupported option, please open a GitHub issue -- <opt>\n, matching the test's stderr assertion.
  • New test file follows sibling conventions in test/js/bun/shell/commands/ (TestBuilder, $.nothrow(), describe.concurrent); .ensureTempDir() and .doesNotExist() exist in test_builder.ts.
  • Checked the other parse_long/parse_short arms for the same copy-paste pattern — none share the bug; the test now pins all 11.
Extended reasoning...

Overview

The PR changes a single string literal in src/runtime/shell/builtin/touch.rs: the b"--time" match arm of parse_long was passing b"--reference=FILE" to unsupported_flag (an obvious copy-paste from the arm directly above), so touch --time x reported the wrong option name. The fix changes it to b"--time". A new test file test/js/bun/shell/commands/touch.test.ts adds a table-driven test pinning stdout/stderr/exit-code and .doesNotExist("file") for all 11 unsupported touch options.

Security risks

None. This changes only a diagnostic string literal in an error path; no parsing, path handling, or syscall behavior is affected.

Level of scrutiny

Low. The Rust change is a one-token literal correction whose intent is self-evident from the surrounding match arms. I verified the exact error format against Builtin::fail_parse / fmt_error_arena ({kind}: unsupported option, please open a GitHub issue -- {opt}\n) — the test's expected stderr matches byte-for-byte. The test file mirrors sibling files (seq.test.ts, rm.test.ts, cp.test.ts) in structure: createTestBuilder, $.nothrow(), .ensureTempDir(), .runAsTest().

Other factors

The test covers the whole class (all 4 long + 7 short unsupported flags), not just the one repro, and asserts the operand file is not created — meeting the "cover the variant matrix" and "strongest invariant" review guidance. The PR description confirms the test fails on released bun 1.4.0 and passes on this branch. touch is registered unconditionally in the builtin kind table (Builtin.rs:191), so no platform gating is needed. No prior reviews or outstanding comments on the PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant