Repository navigation
syntax: expose quote fidelity helpers - #793
Conversation
There was a problem hiding this comment.
💡 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".
d097e9f to
08348b0
Compare
08348b0 to
de977c3
Compare
There was a problem hiding this comment.
💡 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".
| if w.raw == "" { | ||
| w.raw = p.sourceRange(w.Pos(), w.End()) | ||
| } | ||
| if p.braceWordPartsAllowed() { | ||
| w.Parts = splitBraceWordParts(w.Parts) |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
RawText(),UnquotedText(), andWasQuoted()onshell/syntaxWordandPatternSPEC.mdWhy
The upstream quoting bucket needs public AST helpers for quote and raw-text fidelity instead of relying on parser internals or the narrower
VarRefandSubscriptraw-text helpers.Impact
External
shell/syntaxconsumers 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 lintcurrently exits early in this environment withparallel golangci-lint is running; the underlying custom linter invocation above completed cleanly