Repository navigation
fix(executor): stamp expansion-time comsub EOF at construct + body lines + 1 (Refs #3605) - #3675
Merged
Merged
Conversation
…dy lines + 1 (Refs #3605) The ${a+word}/${a-word} path (embedded_mutations.rs) re-processes a '...'-quoted $( as a live command substitution at expansion; when the extracted body runs out without a ')' it reported the construct's own line (current + body_lines - 1) where GNU reports current + body_lines + 1 — command_substitute re-parses the body via parse_and_execute("command substitution", subst.c:7413) without SEVAL_RESETLINE (subst.c:7210), so the base is the script's line_number-1 (evalstring.c:345) and the body's lines plus the EOF read carry it +2 past the construct line. Measured on GNU 5.3.20: one-line body reports N+2, two-line body N+3. run-braces (braces.tests:57 ${a+'$('\\'}" with a=4 set) reported 'command substitution: line 57' vs GNU's 59; now byte-identical. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
Author
|
【WIN-AGENT-AUDIT】 机制核查:
腿:
F 点:无 未跑/VOID 的腿:无 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
run-braces(braces.tests:57):"${a+'$(''}"withaset — the'...'quotes make$(a literal at parse time, but the${a+word}word expansion re-processes it as a real command substitution. When the extracted body runs out without a), rubash reportedcommand substitution: line 57where GNU reportsline 59.command_substitutere-parses the extracted body viaparse_and_execute (string, "command substitution", pflags|SEVAL_NOHIST)(subst.c:7413) withpflags = 0for a non-interactive script (subst.c:7210— noSEVAL_RESETLINE).push_stream(0)keeps the script'sline_numberandline_number--(evalstring.c:345) backs it up one; the body's own lines plus the EOF read then carry the counter toexec_line + body_lines + 1. rubash stampedcurrent + body_lines - 1— two short.Measured on GNU bash 5.3.20:
${a+'$('}at line N reports N+2 for a one-line body, N+3 for a two-line body (${a+'$(x\<newline>y\'}).Refs #3605 (class B, run-braces — clears the suite's only real diff; the
cannot execute binary filenoise belongs to #3586).GNU anchors
subst.c:7413—parse_and_execute (string, "command substitution", pflags|SEVAL_NOHIST).subst.c:7210—pflags = (interactive && sourcelevel == 0) ? SEVAL_RESETLINE : 0.builtins/evalstring.c:345—if (lreset == 0) line_number--.parse.y:6891— yyerror EOF branch reportsline_numberat EOF.Verification (macOS arm64, GNU bash 5.3.20 oracle)
run-braces→ PASS (zero diff).echo "${a-'$(\'}"(line 1 → 3),a=x+echo "${a+'$(\'}"(line 2 → 4), same at line 3 → 5,${a-word}and${a+word}forms.tests/issue3605_comsub_word_eof_line.rs(3 tests).cargo fmt --checkclean.Known residual (not this PR)
A
$(x\<newline>y\'body inside a'...'-quoted${}word still reports one short — the walk's dequoted text collapses the\<newline>before the line count. Separate mechanism (the produced comsub body itself would carry the newline); noted for the next pass.Test plan
cargo test --test issue3605_comsub_word_eof_linerun-bracesPASS