Repository navigation
env-import: BASH_FUNC import diagnostic split; lock imported LINES child-env parity (wave N1) (Refs #2728, #2565) - #3134
Merged
Merged
Conversation
GNU splits a failed BASH_FUNC_*%% import three ways (variables.c
initialize_shell_variables + builtins/evalstring.c SEVAL_FUNCDEF):
a value that fails the raw () { prefix check is silently not a
function; a value that engages the import but fails to parse prints
the parser diagnostics plus the error line and seeds $? = 1; a
value that parses to something other than one straight definition
prints the ignoring-attempt warning plus the error line.
Refs #2728
An imported exported LINES must reach the child environment exactly like COLUMNS (variables.c binds both with att_exported|att_imported; the exported rebuild treats the two names identically). On the current master these pins already pass; they lock the behaviour the issue reported broken. Refs #2565
classify_exported_function_value mirrors the GNU decision tree
(variables.c:395-446): the () { check runs on the RAW value (no
trim, so (){ and a leading space never engage the import and stay
silent); the rebuilt definition name + space + value is parsed and
a parse failure surfaces the parser's own diagnostics converted to
GNU's string-input line numbering (first line is line 0), with the
offending line echoed for the near-token class; a value that parses
to anything other than one straight definition takes the
SEVAL_FUNCDEF warning path (evalstring.c:465-486), with
SEVAL_ONECMD's later-lines-are-never-read rule for multi-line
values. Any failed import seeds $? = 1 (variables.c:440
last_command_exit_value = EXECUTION_FAILURE).
The import now returns ImportedFunctionFailure (Parse with
diagnostics, or IgnoredAttempt) and init.rs prints exactly the
lines GNU prints per class before the single shared error line.
parse_exported_function_body stays as a thin defined-or-not wrapper
for the carrier-comparison caller.
Refs #2728
caomengxuan666
marked this pull request as ready for review
November 10, 2026 03:56
This was referenced Nov 10, 2026
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.
N1 组(180 单令第一波):#2728 修复 + #2565 回归锁。基底
88047f50。Refs #2728
Refs #2565
#2728 — BASH_FUNC_*%% 导入的静默/诊断劈分与形状检查
GNU 决策树(variables.c
initialize_shell_variables:395-446 + builtins/evalstring.c SEVAL_FUNCDEF :465-486、SEVAL_ONECMD :577):STREQN("() {", string, 4)前缀检查(variables.c:404,不 trim)→ 根本没进入函数导入:静默、函数未定义、$?=0。旧 rubash 先 trim 再剥(),(){ echo OK; }与前导空格形都被当成定义接受(lax shape)。from \{' command on line 0形),再跟一行error importing function definition,且last_command_exit_value = EXECUTION_FAILURE(variables.c:440)使$?=1。旧 rubash 把这类与下一类合并成 warning+error 一对、且$?` 恒 0。warning: <name>: ignoring function definition attempt+ error 行;SEVAL_ONECMD 下后续行的内容根本不读,多行值里第二行的命令不影响定义成立。修法(
src/executor/function_env.rs、src/executor/init.rs):新增classify_exported_function_value按上树分类(NotAFunctionValue / ParseFailure / IgnoredAttempt / Defined),合成文本用真名name + " " + value解析;解析诊断从解析器 marker 规格转换到 GNU 的字符串输入行号(首行 = line 0),近 token 类按 GNU 形回显出错行;导入失败经ImportedFunctionFailure枚举回传,init 按类打印,并把任一失败映射到 Executor 初始exit_code = 1。parse_exported_function_body保留为 carrier 对比调用方的 defined-or-not 薄封装。钉
tests/issue2728_bash_func_import_diagnostic_split.rs(11 格):静默三格(非函数值 / 无空格 / 前导空格)、garbage 与if;的解析诊断三行形、ShellShock warning-only 形、未闭合 EOF 诊断形、合法定义运行、尾;/重定向仍定义、换行后命令不读、多行函数体导入。头上 11/0;fail-first 移植基底88047f50实跑 3 过 / 8 红,红格恰为缺陷格(见车道 REPORT)。#2565 — 导入的 exported LINES 不达子环境
在基底
88047f50上已不可复现:captain 立单时验收形态(env LINES=999 COLUMNS=200 <engine> -c 'env'、外部子进程/usr/bin/env、脚本文件、-l、仅 LINES、赋值后)逐一实测,LINES 与 COLUMNS 同步到达子环境、declare -p两名都在。判断为 env 导入/快照种子面在 #3083/#3101 一线合入后被顺手修掉(本组不动代码)。本 PR 只交回归钉tests/issue2565_imported_lines_child_env.rs(4 格:env内建面、真实子进程面、declare -p导出绑定面、展开面),把该行为锁死防再退。关单与否请队长按「已修待锁」口径裁。本 PR 删除了什么
function_env.rs里旧的手工形状检查链:先trim、剥()、trim_start、再对闭合括号后的尾随内容做词法复检的整段(被classify_exported_function_value的 GNU 决策树分类替代);导入失败回传通道由Vec<String>改为类型化枚举,旧的字符串通道随之删除。验证(车道本地,队长复核为准)
RUSTFLAGS="-D warnings"cargo check(lib+bins)零警告;cargo fmt --check干净;python3 scripts/check-marker-literals.pyOK。$?)。dap_pause_during_a_free_run时序 flake、spawn_whitelisted_keeps_extra_handles_at_their_numbersfd 压力形)隔离复跑均绿,实效 1206/0/4,双边总数同为 1210、无新失败名。