Skip to content

fix(interpreter): close Oils tilde, patsub, brace, loop and paren-ambiguity gaps - #2643

Merged
chaliy merged 1 commit into
mainfrom
claude/oils-expansion-ops
Oct 8, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/oils-expansion-ops

Conversation

@chaliy

@chaliy chaliy commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

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

What changed

  • Tilde expansion follows bash: only an unquoted ~ whose prefix ends at / or : expands (~"/b", \~, ~$v stay literal); assignments expand after = and each : (PATH=a:~/bin), also for name= arguments; ${x:-~} expands only unquoted. No user database: ~root → /root, ~<sandbox user> → /home/<user>.
  • ${x/pat/rep}: replacement is literal after quote removal (${v/x/"?"} printed \?x); ${x////c} takes / as the pattern.
  • Brackets: [C\-D] holds a literal -; reversed ranges [z-a] match nothing.
  • Lexer: echo [bin; echo x no longer reads past the ;.
  • Paren ambiguity: ((cmd) ...) / $((cmd) ...) parse as nested subshell / command substitution like bash.
  • Loops: while break; do leaves the loop; ( continue ) only warns; continue 1 2 is "too many arguments".
  • Brace expansion: unclosed { stays literal while later groups expand ({{a,b} → {a {b); step 0 counts as 1.
  • ${v@op}: ${undef@Q} etc. expand to nothing, set -u rejects it, ${x@K} quotes a scalar.

Why

Level-up roadmap: next batch from the Oils harness ranking.

Before / After (verified)

Spec file Before After
tilde 9 1
var-op-patsub 9 2
var-op-bash 8 3
brace-expansion 8 4
glob 5 3
paren-ambiguity 5 0
loop 5 0
Full suite (bashkit vs bash) 77.3% 78.8%

Side gains: command-sub 2 → 0, builtin-eval-source 7 → 5. One case flips (background "Wait for job and PIPESTATUS"): bashkit gives the same output before and after; the old run counted it only because real bash's result for it is racy.

Spot check, identical in bash 5.2 and this branch:

HOME=/h; echo ~ ~"/b" '~' x=~      # /h ~/b ~ x=/h
y=a:~:b; echo $y                   # a:/h:b
v=axb; echo ${v/x/"?"}             # a?b
echo {{a,b} {1..5..0}              # {a {b 1 2 3 4 5
while break; do echo no; done      # (no output, loop exits)

Risk

  • Expansion is a core path; new spec files (tilde-expansion, patsub-replacement, loop-control, paren-ambiguity) plus additions, all verified against bash. bash-oracle unchanged at 104/102.
  • Stack for depth_32_no_stack_overflow: ~1,888,007 bytes vs 1,892,032 on the base; no new awaits in hot paths.
  • Left: var-op-test (needs arrays / ${!ref}, owned elsewhere), bash's brace "double expansion" quirk, command-name globbing (would add an await to the hot path), globskipdots, LC_ALL=C byte matching. Recorded in limitations.

Checklist

  • Failing tests first, verified against bash 5.2
  • fmt, clippy, integration, lib, terminal, CLI, bash_comparison, check-okf, bash-oracle
  • knowledge updated (log, limitations, oils-spec headline + saved run)

Generated by Claude Code

…iguity gaps

Tilde expansion follows bash's rules: only unquoted prefixes ending in the
same literal expand; assignments expand after = and each : (also name=
arguments); ${x:-~} operands expand unquoted, pattern operands always.
~root and the sandbox user resolve; other users stay literal.

${x/pat/rep} replacements are literal after quote removal; ${x////c} and
${x///} take / as the pattern. Bracket expressions honor \- and treat
reversed ranges as empty; [bin; ends at the metacharacter.

((cmd) ...) and $((cmd) ...) parse as subshells; `(cmd)` is not $((.
while break leaves the loop, (continue) in a loop only warns, continue 1 2
abandons the line. {{a,b} and zero-step ranges expand like bash. Unset
${v@Q}/@K/@A expand to nothing; set -u rejects them; ${!p@} lists arrays.

Oils spec pass rate 77.3% to 78.8%.
@chaliy chaliy self-assigned this Oct 8, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 8, 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 8645536 Commit Preview URL

Branch Preview URL
Oct 08 2026, 01:40 PM

@chaliy
chaliy merged commit 8b01ed2 into main Oct 8, 2026
46 checks passed
@chaliy
chaliy deleted the claude/oils-expansion-ops branch October 8, 2026 14:08
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