Repository navigation
[continuation] fix: Wave2c P2 batch - arithmetic dollar-brace, export array env leak, tempenv absorption, substring sq operands, raw-byte escapes, dynamic var cells, compound-assignment rc - #573
Merged
Conversation
…env leak, tempenv absorption, substring sq operands, raw-byte escapes, dynamic var cells Eight P2-medium parse/expand/env semantic bugs, each WSL GNU bash 5.3.0 verified before and after: - #533 arithmetic body dollar-brace: an unterminated ${ inside $(( ))/ $[ ]/(( )) is P_ARITH literal text (parse.y parse_matched_pair), the unit's own closer wins at parse time, EOF names )/], and the closed form reports expansion-stage bad substitution rc 1 with the script continuing (subst.c bad_substitution). Owners: brace_scan param scan arithmetic-unit skip, continuation.rs unclosed scanners, parameter_errors + arithmetic funnel. - #534 export arrays: make_env_array_from_var_list skips array/assoc cells (ARRAY_EXPORT off) - export/readonly/declare -x no longer publish the storage form into the process env, and the child env assembly (apply_child_environment / child_shell_environment / exec / env) filters array-typed names. - #538 tempenv absorption: setattr.def set_var_attribute absorbs ONLY the operands a builtin names (setattr.def:590-614) - FOO=val export BAR leaves FOO unset; absorbed bindings keep the tempenv's exported attribute (setattr.def:604). set -a (mark_modified_vars) now also marks valueless declare bindings exported (variables.c bind_variable). - #539 substring operands reach evalexp raw: a single-quoted span is a string operand (verify_substring_values), never stripped like the double-quoted form; the extquote $'...'-as-name decode applies in quoted context including substring offsets and comsub bodies. - #540 raw-byte escapes: printf \xHH is a byte escape on the format and %b paths (printf.def:1108-1124 tescape, *cp = evalue & 0xFF), and declare -p quotes marker-carried bytes from the byte view so $'\x81' renders $'\201'. - #541 dynamic variables are registered cells: declare -p renders the current dynamic value with the cell attributes (RANDOM/SECONDS/...), and unset FUNCNAME stays unbound across function entries (variables.c:1812 make_funcname_visible). - #542 compound-assignment EOF exit family: any construct pending inside name=( takes the assignment's rc 1 family (parse.y:7140-7152). New regression tests: tests/issue53{3,4}*, issue538*, issue539*, issue540*, issue541*, issue542* (16 cases, GNU-verified expectations).
…rflow read, fatal at the comsub parse level (1 comsub case still red)
… parked overflow in the unclosed-comsub sweep before its own EOF hunt; driver fatal skips unclosed prefixes
The comsub body's tokenize parks HEREDOC_MAX overflow in
HEREDOC_OVERFLOW_LINE, but at execution the body is expanded as a folded
word and the unclosed-comsub sweep (command_execute) reported its own
'residual $(' EOF hunt — 17 gather warnings plus 'unexpected EOF while
looking for matching ')'' — while the parked fatal went unreported.
GNU dies at the 17th push_heredoc with only 'maximum here-document
count exceeded' at the offending line (verified via WSL bash 5.2/5.3
across top-level/comsub/same-line/newline/prefix shapes, all rc 2).
Consume the parked overflow in that sweep ahead of the replay; the
driver-level fatal additionally skips prefixes that are themselves
unclosed (a '$(' whose body carries the offending heredocs never
completed, so re-running its line standalone would emit a phantom
diagnostic ahead of the fatal).
Tests: issue543 suite 12/12 (f2_seventeen_pending_inside_command_
substitution_is_fatal red->green); upstream_suite_slice_snapshots and
the full regression suite 27/27 (the #573 exp red is the ${#RANDOM}
declare -i reseed, already fixed by apply_declare_random_seeds in the
WIP commit); UTF-8 boundary hygiene clean.
caomengxuan666
added a commit
that referenced
this pull request
Oct 13, 2026
…licitly command_prepare.rs's function-call redirect gate calls finish_heredoc_expansion_error for its exit-code store and drops the run/continue verdict (shape carried over the 32f9260 base on both sides, unchanged by the #573 merge). The bare call trips unused_must_use once the crate builds under RUSTFLAGS=-D warnings; make the discard explicit. No behavior change.
caomengxuan666
added a commit
that referenced
this pull request
Oct 13, 2026
…are drive-root POSIX form (#564 #565 #566) (#577) * fix: Wave4c batch - operator-position procsub line joins, empty fnhead newline naming, bare drive root cd (#564/#565/#566) #564: GNU read_token (parse.y:3776-3796) declines the `<'/`>' operator when peek_char == '(' and falls into read_token_word, whose shellexp arm (parse.y:5494-5524) reads the `(...)` body via parse_comsub (parse.y:4451) across physical newlines - ONE word token regardless of what precedes the introducer. rubash's group reader committed the logical line after the introducer line, so `cat <(echo' NL `echo hi' NL `)' died with `syntax error near unexpected token `(''. Three pieces: the one-shot unclosed-input oracle (continuation.rs) and the incremental close-char residual scanner now push the body's `)' matched pair when an ADJACENT `(' follows the redirect operator (the K5 tail park covers the buffer edge), the join gate extends to operator-position bodies via the text-level oracle line_ends_in_open_operator_process_substitution (the exact complement of the #463 word-attached gate), and the procsub source reconstruction folds only STRAY joined newlines back to `\n' (leading, or doubled after `;'/`;;' - positions where a reconstructed `;' is a syntax error a newline never is) while mid-body and trailing separators keep the `;' spelling the #373/#381/#390 adjudication pins (`case esac in ; esac', `echo bye ;'). Acceptance: WSL GNU 5.3.0 `cat <(echo hi\necho hi2\n)' runs BOTH lines and the script continues, `echo <(echo\necho hi2\n)' still evaluates to /dev/fd/N; 11 new tests green, 4 RED on fresh master d116874. #565: the shifted `(' of the function_def production (parse.y:1054 via read_token's parse.y:3774-3790 classification) is the token stream's LAST token for a final line without a terminator. GNU's reader still hands yacc the physical line's NEWLINE and rejects THAT: `syntax error near unexpected token `newline'' + print_offending_line of the `(' line (parse.y:6814; WSL GNU probes: `[ (` NL, `f (` NL, `echo (` NL and `bash -c '[ ('` all name `newline', never `('). The name_override arm now maps that nothing-after-the-shifted-paren shape to `newline' without touching the #563 C4b neighbours (two+ words still name the `(' itself). `x=1 (' is pinned as the #452 adjudication boundary, NOT a GNU cell: rubash accepts assignment-prefix + subshell (real GNU 5.3.0 rejects even the raw corpus shapes), so the reader's join stands and clean EOF reports the `unexpected end of file from `(' command' diagnostic at the EOF line. Harness: the stdin driver binds argv[0] as the diagnostic program name, so the file normalizes the exe path to `bash' like the #551 harness. 9 tests green, 4 RED on fresh master. #566: boundary contract B1 (docs/windows-path-contract.md L1) accepts the drive-form operands `/c/...', `/c/', `/c/.', `/D' - but the BARE root `/c' slipped past shell_path_to_windows_inner's drive arm (len >= 3 with a slash at byte 2) into the shell-root mapping, where map_logical_path resolved it to <root>/c -> ENOENT: `cd /c' failed while `cd /c/' worked, and a root carrying a `d/' directory made `cd /d' work by coincidence. The drive arm now maps the bare root to the drive root (case-insensitive) and map_logical_path's drive-form exclusion covers the two-letter spelling; `cd /c' renders the POSIX `/c/' exactly like its slashed sibling, and a same-named root child no longer shadows the drive. Contract doc ledger and the suite's "filed separately" note updated. 7 tests green, 5 RED on fresh master. * fix(executor): discard the FatalNounset heredoc-expansion verdict explicitly command_prepare.rs's function-call redirect gate calls finish_heredoc_expansion_error for its exit-code store and drops the run/continue verdict (shape carried over the 32f9260 base on both sides, unchanged by the #573 merge). The bare call trips unused_must_use once the crate builds under RUSTFLAGS=-D warnings; make the discard explicit. No behavior change.
caomengxuan666
added a commit
that referenced
this pull request
Oct 13, 2026
…cise Master's #573 wave flipped the two dparen EOF arms in run_source_impl (dparen_arith_group_never_closes, dparen_subshell_reparse_compound_eof) to a dual-char `) [' wording. GNU's EOF reports carry a single char: parse.y:3912 prints the matched-pair close char, parse.y:7152 the literal )' - a `) [' report has no GNU oracle, and no test on either side pins it, while the #390/#413 wording pins (issue390 q1 family, issue413 dparen_verdict_arithmetic_side_stands) exercise `)' and pass on the pre-merge branch. Restore the `)' wording in the merge so the branch's dparen-verdict semantics (#543 a1/a3: the dparen family owns the )' verdict) survive master's rewording; master's other #573 changes in the region are untouched.
caomengxuan666
added a commit
that referenced
this pull request
Oct 13, 2026
…rap list/DEBUG freeze, bash -o listing, jobs/alias params (#543 #544 #545 #546 #547 #549) (#578) * WIP(wave4b): #543 dollar-bracket EOF scan + #544 declare -aA conflict (checkpoint before master merge) * WIP(wave4b): #545 procsub lifetime+xtrace, #546 trap cells, #547 -o listing, #549 jobs/alias (checkpoint 2) * fix(wave4b): #545 procsub fd lifetime + [[ ]] operand realization/xtrace, #546 trap listing/BASH_COMMAND freeze, #547 bash -o list form, #549 jobs lenient specs + alias -p whole-table, #544 -aA tests, #543 locks * fix: discard best-effort heredoc-expansion-error Result in function-call redirect rejection arm RUSTFLAGS=-D warnings surfaced an unused-must-use on the FatalNounset arm's finish_heredoc_expansion_error call (present on master 40586ca as a bare statement). The command's result is decided by the rejection status after the temporary-assignment restore, so the materialization Result is deliberately discarded - mirror the let _ = contract the posix-assignment-failure arm already uses for its finish calls. * test(#545): pin scalar-assignment stored procsub path as dead after the creating command part_080's assignment input-procsub test still pinned the pre-#545 contract (stored /dev/fd/N stays readable, cat prints alpha). The fd lifetime fix reaps a command's substitutions when the creating command finishes (GNU execute_cmd.c:832 delete_procsubs closes fds or unlinks fifos; WSL GNU 5.3.0(1) probe 2026-10-12), and the array form of the same contract is already pinned in issue545_procsub_lifetime_xtrace_ regressions. Flip the scalar form the same way part_072's operand matrix was flipped: cat reports ENOENT rc 1, redirect target stays empty. Same-family flips in this PR: part_035 (#549), part_072 (#545). * fix(#390): keep the single-char dparen EOF wording the #390 pins exercise Master's #573 wave flipped the two dparen EOF arms in run_source_impl (dparen_arith_group_never_closes, dparen_subshell_reparse_compound_eof) to a dual-char `) [' wording. GNU's EOF reports carry a single char: parse.y:3912 prints the matched-pair close char, parse.y:7152 the literal )' - a `) [' report has no GNU oracle, and no test on either side pins it, while the #390/#413 wording pins (issue390 q1 family, issue413 dparen_verdict_arithmetic_side_stands) exercise `)' and pass on the pre-merge branch. Restore the `)' wording in the merge so the branch's dparen-verdict semantics (#543 a1/a3: the dparen family owns the )' verdict) survive master's rewording; master's other #573 changes in the region are untouched.
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.
八条 P2-medium 解析/展开/环境语义 bug(#533 #534 #538 #539 #540 #541 #542)
每条均先取 GNU bash 5.3.0(WSL stdin/script-file 双法)行为基线并复现存证,修后逐格与 GNU 对齐;一手判定锚定 vendored 源码 third_party/bash/(file:line 见各条)。
#533 算术体内未终止
${(吞算术闭合符)${(非 FUNSUB${|)是字面文本,\))/]先闭合;展开期 subst.c bad_substitution 报1+${x: bad substitutionrc=1,仅弃当前命令、脚本继续;未闭合形态 EOF 命名)'/]'。$[传统形式一并覆盖);executor 侧 funnel 的 bad-substitution 判定(parameter_errors/parameter_core/arithmetic/mod)。$((/$[/dparen 推入)。#534 export 数组泄漏子进程 env
continue(ARRAY_EXPORT 未开)——export 属性保留(declare -p 显示 -a -x)但名称不进子 env。#538 export 前缀赋值过持久 + allexport 无值声明
FOO=val export BAR后 FOO unset;具名形态持久),吸收继承 tempenv 属性含 exported(setattr.def:604)。#539 子串操作数引号 + extquote
x: '2': arithmetic syntax error: operand expectedrc=1),不像双引号形态被剥除。$'…'-as-name 解码在带引号上下文生效,含子串 offset 与 comsub 体("${x:\{\$'1'}}→abcdef、"$(echo \{$'a'})→zz);顶层无引号仍 bad substitution。${$$'1'}→$1)。#540 字节再编码
\xNN为字节转义(*cp = evalue & 0xFF),format 与 %b 两路;strtrans.c ansic_quote 按原始字节流转义。\x改走 format_escape_byte;declare/storage.rs quote_declare_value 对带 raw-byte 标记的值改为从字节视图引用($'\x81'→$'\201',不再$'\302\201')。#541 动态变量
declare -p RANDOM→declare -i RANDOM="…"(显示时重估),RANDOM/SECONDS/SRANDOM/BASHPID 带 -i,EPOCH*/LINENO/BASH_SUBSHELL/BASH_ARGV0/BASH_COMMAND 为 --,GROUPS 为 -a。unset FUNCNAME解绑后函数入口 find_variable 失败不再重建,${FUNCNAME[0]}保持空。#542 复合赋值内 parse 错 rc 2→1
name=(内任何未闭合构造走赋值自身的 rc 1 家族(error.c:324-327 仅 errexit 时强制 2)。master fix(#551): C-family message formats - EOF naming, [[ =~ two-part diagnostic, single-cut stdin line numbers, write-error prefix #563 已含同款折算(array_list: stack.iter().any),本分支 rebase 后直接采纳;四形态(v=($(echo/v=(\echo/v=("$(echo)/v=("`)消息与 rc 均与 GNU 一致。continuation.rs 改动(授权项)
$[推入(]、arith 标记);相邻\((内层推入的 arith 标记(形状推导:report_open && !command == 相邻位);`$"+"{`` 臂对 arith 顶的非 funsub 字面跳过;返回的 array_list 语义扩展为栈内任一 array-list 祖先([exit-status] 复合赋值/数组字面量内 parse 错误退出码:v=($(echo、v=(`echo、v=(" 未终止引号 → rc=2(GNU rc=1,消息行号全对)(P2) #542)。$[推入、arith 字面跳过、K5 相邻\((未决停车)。$[与\))-收口\((的不透明跳过(未决停车+惰性直落)。$(( ... $(...) ... ))、heredoc 体、\\-续行(wave2c 既有 heredoc/comsub 回归全绿);\((未闭合走 subshell 语义的守护测试(((echo hi); cat 双侧一致)+ brace_scan 单元测试。测试证据
$((…))词路径 bad substitution 后的 ExpansionFailure 影响范围是前一条命令(GNU 为整行 list)——z1 形态多弃一条命令;${$$'a'}顶层无引号的 bad-substitution 消息显示形态(GNU 剥 $ 前缀)属 huck#8 记录的 display residual。Closes #533, closes #534, closes #538, closes #539, closes #540, closes #541, refs #542(#563 已含其折算,本分支补回归测试)。