ReviewOS

home-lang/home

Preserve Bun shell interpolation as literal data

#689
Closed chris opened this 9 days ago ·
9 days ago

The exact untouched Bun bunshell.test.ts matrix currently has a 21-failure baseline in Home. Ten failures share one parser/expansion root: bytes arriving through template interpolation are being reinterpreted as shell syntax.

Scope:

  • protect the internal JS-string marker in $.escape output;
  • preserve interpolated tilde and dash arguments as literal data;
  • prevent interpolated glob metacharacters from broadening matches while keeping literal template glob syntax active;
  • prevent interpolated equals signs from becoming environment assignments;
  • retain current behavior for literal tilde, glob, assignment, and brace syntax.

Baseline: full native VM, exact Bun fixture at 4982b91. Overall file: 357 pass, 83 upstream TODO, 21 fail. This issue tracks the coherent interpolation subset only. No fixture edits or relaxed assertions.

9 days ago

Implemented and pushed in e83b67b.

Ported Bun shell semantics:

  • Track strpool byte ranges originating in interpolated JS strings and prevent interpolated equals signs from becoming shell assignments.
  • Keep interpolated leading tildes literal, including cd arguments.
  • Break hostile internal string-reference sentinels during escaping so user data cannot be re-read as interpolation metadata.
  • Generalize expansion provenance across brace and glob metacharacters, neutralizing glob syntax introduced by interpolation, variables, or command substitution while preserving literal source asterisks and double-asterisks.
  • Preserve the original user pattern in no-match diagnostics.
  • Route glob walker failures through the shell state machine; classify ENOENT and ENOTDIR as ordinary no-match outcomes while keeping permission failures catchable.

Validation:

  • ReleaseFast/JSC production build passed.
  • Exact upstream fixture remains byte-identical to Bun checkout 4982b91.
  • Strict full native-VM shell baseline: 357 pass, 83 upstream TODO, 21 fail, 1 error, 991 assertions.
  • After this commit: 369 pass, 83 upstream TODO, 9 fail, 0 inter-test errors, 1028 assertions.
  • The exact 461-test run repeated with the same 369/83/9 result.
  • No test file, skip, deadline, workload, or assertion was changed.

This removes 12 failures from the unchanged shell suite and completes this focused issue.

Sign in to comment on this issue.