Skip to content

fix(shell): preserve quoted case-modified arguments - #784

Open
Prasad-178 wants to merge 5 commits into
vercel-labs:mainfrom
Prasad-178:fix/quoted-case-modified-arguments
Open

Prasad-178 wants to merge 5 commits into
vercel-labs:mainfrom
Prasad-178:fix/quoted-case-modified-arguments

Conversation

@Prasad-178

@Prasad-178 Prasad-178 commented Nov 30, 2026 •

Copy link
Copy Markdown

Addresses item 4 of #758.

Apply case modification per value for quoted array and positional argument expansions. The @ forms preserve argument boundaries and the * forms join using the first character of IFS. With adjacent text inside the quote, attach it to the first and last arguments. Single-character case operators with an explicit pattern check the leading character.

Verified 18 cases directly against GNU Bash 5.3.9. The regression suite also checks that aggregate output still respects the string limit. Interpreter and adjacent limit suites passed with 1,379 passed and one skipped. Typecheck and changed-file lint passed.

A clean checkout also passed the repository lint, build, and all 1,059 comparison tests.

The full local unit run had 15,377 passes, 98 skips, and four filesystem test failures. All four failures also reproduced on the untouched upstream commit on this machine.

@vercel

vercel Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

@Prasad-178 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@auto-maintain

auto-maintain Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🤖 auto-maintain review

Automated, advisory triage for @Prasad-178's PR. Facts below are read from the GitHub API.

Check Result
Author's merged PRs (this repo) 0 — ⚠️ first-time contributor
Account established ✅ (age 1794d · 20 followers · 75 public repos)
Commits signed/verified ✅ 4/4
Changeset included ✅ (.changeset/quoted-case-arguments.md)

Review panel: 🟡 medium highest severity

just-bash maintainer code review: 🟡 medium

The core fix works for covered cases, but the new expansion path breaks neighboring list operations and brace-produced tilde expansion.

  • packages/just-bash/src/interpreter/expansion/word-glob-expansion.ts:718 — Other quoted list operations beside a case-modified expansion are collapsed to one string at this fallback. For example, `a=(x y); b=(z); set -- "${a[@]/x/X}${b[@]^}"` should produce `X` and `yZ`, but the pattern replacement is expanded as `X y`, yielding one argument. Preserve boundaries for all word-producing `@` operations.
  • packages/just-bash/src/interpreter/expansion/word-glob-expansion.ts:155 — The brace-special path converts alternatives to literals and bypasses the usual post-brace tilde expansion. A word such as `~{root,}/"${a[@]^}"` therefore leaves `root` and `` unexpanded whenever the quoted case-modified array triggers this path.

General code review: 🟡 medium

The new quoted-case expansion path still loses argument boundaries for nested brace alternatives and adjacent list-producing parameter operations.

  • packages/just-bash/src/interpreter/expansion/word-glob-expansion.ts:149 — Quoted case modification is detected only at the top level. In `{x"${a[@]^}",y}`, the expansion is nested inside `BraceExpansion`, so it follows the old scalar path and collapses the array instead of producing `xAb`, `Cd`, and `y`. Search brace alternatives recursively or detect after preserving brace parts.
  • packages/just-bash/src/interpreter/expansion/word-glob-expansion.ts:718 — The compositor scalarizes neighboring multi-value operations not recognized by `isQuotedListParameter`. For `a=(ax bx); b=(c d); set -- "${a[@]/x/z}${b[@]^}"`, the pattern replacement becomes one `az bz` value, yielding two arguments instead of Bash's `az`, `bzC`, and `D`. Preserve boundaries for all array/positional list-producing operators.

Adversarial security: 🟢 low

No actionable adversarial security issues found in the complete diff.

Adversarial security (second opinion): 🟢 low

Self-contained word-expansion fix with no untrusted-input, networking, dependency, or sandbox-limit implications; glob escaping and execution limits are correctly preserved on the new code path.

Standard Bash and host portability: 🟡 medium

The quoted case-modification implementation loses boundaries when combined with other array operations and remains incorrect for redirect targets.

  • packages/just-bash/src/interpreter/expansion/word-glob-expansion.ts:557 — The special path flattens adjacent quoted array expansions with operations other than case modification or substring. For example, `"${a[@]/a/A}${b[@]^}"` should produce `Ab`, `cdEf`, `Gh`, but the first array is expanded as one space-joined string, losing an argument boundary.
  • packages/just-bash/src/interpreter/expansion.ts:572 — Redirect ambiguity detection excludes case-modified `$@`. With two positional parameters, `: > "${@^}"` must fail with an ambiguous redirect in Bash, but this path joins the parameters and accepts a single filename.

Posted by auto-maintain. This automated code review is advisory; a human maintainer makes the call.

@privatenumber privatenumber added awaiting-review Maintainer review or re-review is next. Does not imply approval or merge readiness. bug Something isn't working p2 Normal backlog action. Priority is not acceptance or a delivery promise. shell Parsing, quoting, expansion, pipelines, redirection, and shell execution labels Dec 1, 2026

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

awaiting-review Maintainer review or re-review is next. Does not imply approval or merge readiness. bug Something isn't working p2 Normal backlog action. Priority is not acceptance or a delivery promise. shell Parsing, quoting, expansion, pipelines, redirection, and shell execution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants