Skip to content

syntax: expose quote fidelity helpers - #793

Merged
ewhauser merged 1 commit into
mainfrom
ewhauser/syntax-quote-fidelity
Mar 30, 2026
Merged

ewhauser merged 1 commit into
mainfrom
ewhauser/syntax-quote-fidelity

Conversation

@ewhauser

Copy link
Copy Markdown
Owner

Summary

  • expose RawText(), UnquotedText(), and WasQuoted() on shell/syntax Word and Pattern
  • move quote-removal into shared fidelity helpers and capture raw text centrally in parser word/pattern construction paths
  • add parsed, synthetic, typedjson, extglob, and regex fidelity coverage and document the parse-only raw-text contract in SPEC.md

Why

The upstream quoting bucket needs public AST helpers for quote and raw-text fidelity instead of relying on parser internals or the narrower VarRef and Subscript raw-text helpers.

Impact

External shell/syntax consumers can now distinguish original parse text from quote-removed text on words and patterns without reparsing or reimplementing shell quote removal.

Validation

  • go test ./shell/syntax/...
  • go test ./shell/...
  • ./custom-gcl run ./...
  • make lint currently exits early in this environment with parallel golangci-lint is running; the underlying custom linter invocation above completed cleanly

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d097e9f74d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread shell/syntax/fidelity.go Resolved
@ewhauser
ewhauser force-pushed the ewhauser/syntax-quote-fidelity branch from d097e9f to 08348b0 Compare March 30, 2026 03:06
@ewhauser
ewhauser force-pushed the ewhauser/syntax-quote-fidelity branch from 08348b0 to de977c3 Compare March 30, 2026 03:17
@ewhauser
ewhauser merged commit b6eaa1f into main Mar 30, 2026
16 checks passed
@ewhauser
ewhauser deleted the ewhauser/syntax-quote-fidelity branch March 30, 2026 03:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de977c3570

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread shell/syntax/parser.go
Comment on lines +2790 to 2794
if w.raw == "" {
w.raw = p.sourceRange(w.Pos(), w.End())
}
if p.braceWordPartsAllowed() {
w.Parts = splitBraceWordParts(w.Parts)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve raw text when splitting brace expansion words

finishWord stores w.raw before splitBraceWordParts runs, but brace splitting creates new *Word nodes for BraceExp.Elems (shell/syntax/braces.go) without ever populating their raw field. As a result, words that come from parsed brace elements (for example {foo,bar}) report RawText()=="" even though they are parse-produced nodes, which breaks the new quote-fidelity API for callers traversing element words. Populate raw on split-generated element words (or derive it after splitting) so parsed brace-element words keep their source text.

Useful? React with 👍 / 👎.

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