Skip to content

fix(interpreter): close Oils word-split, globignore, dbracket, cd and alias gaps - #2641

Merged
chaliy merged 1 commit into
mainfrom
claude/oils-wordsplit-glob
Oct 8, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/oils-wordsplit-glob

Conversation

@chaliy

@chaliy chaliy commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

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

What changed

  • Word splitting: only expansion results are IFS-split, not the literal text of an unquoted word. Single-quoted segments stay whole, $x"" keeps an empty field, quoted text in ${v:-"..."} stays whole, unquoted $*/$@ join on the first IFS char then split, ${#v} splits.
  • Lexer: "a"$((k++)), "a"$(cmd) and "a"${x:-y z} no longer get cut short; [\\] and *\(\) match literally.
  • GLOBIGNORE: :-separated patterns (brackets respected), whole-path match, ./.. dropped, non-empty value enables dotglob, empty result falls back like bash.
  • [[ ]]: parse-time grammar check gives bash's syntax errors with status 2; newlines are blanks; quoted '!'/'(' are operands; FOO=bar [[ is a command lookup (127).
  • cd/pwd: -L/-P/-e/-@/--, too many arguments, OLDPWD not set, CDPATH, cd - prints, cd nope/.. fails, pwd -P.
  • alias: alias --/-p, unalias --, trailing-blank chaining, prefix assignments kept, backquoted args re-parse (Word Display no longer uses Debug for command substitutions, TM-INF-022).

Why

Level-up roadmap: the first Oils harness run ranked these among the biggest gaps.

Before / After (verified)

Upstream Oils spec suite (scripts/oils-spec/run.py), misses among cases real bash passes:

Spec file Before After
word-split 16 0
globignore 16 1
dbracket 13 1
builtin-cd 14 5
alias 13 7
Full suite (bashkit vs bash) 74.2% 77.3%

No new misses in any other spec file (full fails list diffed). Saved run committed for /benches.

Spot check, output identical in bash 5.2 and this branch:

x="a  b"; printf '<%s>' pre$x"q r"'s t'      # <prea><bq rs t>
set -- "1 2" 3; IFS=:; printf '<%s>' $*      # <1 2><3>
e=; printf '<%s>' $e"" ""$e""                # <><>
printf '<%s>' ${u:-"p  q" r}                 # <p  q><r>
GLOBIGNORE='*.b'; echo *                     # .c a.a

Risk

  • Word splitting and the lexer are core paths; covered by new spec cases (word-split, glob-options, conditional, alias, new cd-builtin) all verified against bash, plus existing suites. bash-oracle unchanged at 104/102.
  • Stack for depth_32_no_stack_overflow: 1,892,032 vs main 1,896,064 bytes (alias expansion boxed and only called for defined aliases).
  • Left (limitations.md): parse-time alias expansion (7 alias cases), $PWD not user-settable, globskipdots, tilde on the right of =~.

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)

Generated by Claude Code

… alias gaps

Field splitting splits only expansion results: literal text, quoted parts
(including single quotes and empty quotes) and quoted text in a used
${v:-...} operand stay whole. Unquoted $*/$@ join on IFS[0] and split; a
null IFS keeps one field per parameter. ${#v} splits; ${!a[*]} and
${!prefix*} are distinct from their @ forms. "a"$((..)) / "a"$(..) read
their expansion whole; [\\]_ and *\(\) lex as bash does.

GLOBIGNORE filters glob matches (FNM_PATHNAME, dotglob on, . and ..
dropped). [[ ]] is checked against bash's conditional grammar at parse
time (status 2), quoted '!'/'(' are operands, newlines are blanks,
FOO=x [[ runs a command, and $(...) stderr follows the redirects.
cd gains -L/-P/--, CDPATH, cd - printing, bash's errors; pwd -P.
alias/unalias accept --/-p, trailing-blank chaining continues, prefix
assignments survive, backquoted args re-parse, expansion syntax errors
exit 2. Word Display prints command substitutions as shell text.
@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 0c3b32d Commit Preview URL

Branch Preview URL
Oct 08 2026, 11:57 AM

@chaliy
chaliy merged commit 98e1bf8 into main Oct 8, 2026
46 checks passed
@chaliy
chaliy deleted the claude/oils-wordsplit-glob branch October 8, 2026 12:25
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