You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[lexer] digit word before whitespace-separated << is taken as the heredoc fd (head -n 3 <<X loses the 3; GNU parse.y:5731 requires adjacency) #2467
P1-high高:核心语义或高频路径受损,影响日常使用/发布area:parserlexer/parser: heredoc collection, comsub body re-parse, quoting statebugSomething isn't workinggnu-baselineTracked by the GNU Bash 5.3.0 true-baseline ledger
/* Check to see what thing we should return. If the last_read_token is a `<', or a `&', or the character which ended this token is a '>' or '<', then, and ONLY then, is this input token a NUMBER. Otherwise, it is just a word, and should be returned as such. */ifMBTEST(all_digit_token&& (character=='<'||character=='>'||last_read_token==LESS_AND||last_read_token==GREATER_AND))
character 是终止该 token 的那个字符。3 <<X 里终止 3 的是空格而非 <,所以 3 是 WORD 不是 NUMBER;语法 NUMBER LESS_LESS WORD(parse.y:629)只在 NUMBER 与 << 相邻时成立。rubash 在空白分隔时仍把前一个数字单词粘合成了 io_number(3<<)。
P1-high高:核心语义或高频路径受损,影响日常使用/发布area:parserlexer/parser: heredoc collection, comsub body re-parse, quoting statebugSomething isn't workinggnu-baselineTracked by the GNU Bash 5.3.0 true-baseline ledger
Activity
Merge pull request #2468 from unixwin/fix/2467-heredoc-fd-spacing
caomengxuan666 commentedon Nov 1, 2026
已修复并合入 master:PR #2468(merge
fa34dbff),niu 跟踪单 niubash#791 随 pin 升与产品面钉另行关单。根因:不在词法层,在 parser。
src/parser/token_actions.rs的TokenKind::HereDoc臂是全仓唯一不查相邻性的重定向臂——它走take_heredoc_fd_prefix→take_redirect_fd_prefix(src/parser/redirections.rs),后者无条件弹出命令最后一个全数字词当 fd。于是处理<<时把参数3弹走。词法侧三条路径(number_redirect、scanner 的 finish_prefixed_input_redirect、alias_stream 数字词规则)经核查都只在紧贴时融合,无误;其余每个重定向臂都走带 column 相邻性检查的take_adjacent_redirect_fd_prefix,唯独 HereDoc 臂例外。GNU 依据:parse.y
read_token_word()的 got_token 裁决——全数字 token 仅当终止字符是</>时才是 NUMBER,空格终止即 WORD;parse.y:629NUMBER LESS_LESS WORD只对融合拼写成立。在 token 模型里「被<终止」⇔ 数字词 column 终点 == 操作符 column,正是相邻性检查所测。修复:HereDoc 臂改走
take_adjacent_redirect_fd_prefix,与全部兄弟臂一致;删除失去唯一调用者的 wrapper。2 文件 +12/−6。融合形态(3<<X)走redirect_operator_fd在 or_else 之前命中,逐字节不变。范围说明(一处按机制扩围,特此记账):空格形
echo 3 <<-X与<<同臂同病(GNU 印3、修复前被吞),已随本修复一并转正并钉住;融合形3<<-X(#2265 面)修复前后全绿、字节不变。验证(scrubbed fd 环境,主会话在 PR 头 43a147f 复跑):
tests/issue2467_heredoc_fd_spacing.rs(13 钉):未修 master 7 passed / 6 failed(6 正例全红、7 阴性全绿)→ 修复后 13/13。3 <<X无命令名、echo 3 4 <<X)。continuation.rs未触及。test(heredoc): pin the spaced-<< io_number swallow (Refs unixwin#2467)
fix(parser): heredoc fd prefix requires token adjacency (Refs unixwin…