Skip to content

[bug] compgen -C with empty current word sets COMP_CWORD=0 (GNU: empty) #1796

Closed

Description

@caomengxuan666

形状

compgen -C <cmd> 以空 current word 调用时,被调用命令环境里的 COMP_CWORD 取值分歧:GNU 为空,rubash 给 0。其余变量(COMP_LINE/COMP_WORDS/COMP_POINT)两边一致。

复现(master 202de47,GNU oracle = 自编 bash 5.3.20,两轮同集)

compgen -C 'printf "LINE=[%s] CWORD=[%s] WORDS=[%s] POINT=[%s]\n" "$COMP_LINE" "$COMP_CWORD" "$COMP_WORDS" "$COMP_POINT" > cinfo.txt' '' 2>/dev/null; cat cinfo.txt
# GNU:    LINE=[] CWORD=[] WORDS=[] POINT=[0] ...
# rubash: LINE=[] CWORD=[0] WORDS=[] POINT=[0] ...

compgen -C 'printf "LINE=[%s] CWORD=[%s]\n" "$COMP_LINE" "$COMP_CWORD" > cinfo.txt' foo 2>/dev/null; cat cinfo.txt
# GNU 首行:    LINE=[] CWORD=[]
# rubash 首行: LINE=[] CWORD=[0]

出处

diff-hunt r9 裁定(cases cc06、cc07),两轮同集:~/workspace/rubash-hunt-runs/2026-10-26-r9/results-r8-pass1.json。与旧案 #146(补全函数内 COMP_CWORD 为空)相邻但形状不同:本条是 -C 空 word 时不应合成索引 0。

归宿

compgen 族修复簇(r9 同批)。在飞线收完后开簇。修复须带回归钉(测试名含本 issue 号、断言 GNU 期望)。

Regression seed: cc06、cc07。

Activity

  1. added
    bug
    gnu-baseline
    P2-medium
    area:builtins
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2-mediumarea:builtinsbuggnu-baseline

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions