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
grep/sed: [^:] and [^x] stop after the first byte of a multi-byte character #1907
: is ef bc 9a and 开 is e5 bc 80. With -a, the first command prints e5 8f af e5 (可 plus the first byte of 开), and printf '开\n' | grep -c '^[^x][^x][^x]$' prints 1. grep -P gives the GNU output, and LC_ALL makes no difference. . is not affected: printf '中\n' | grep -c '^.$' prints 1.
The grep -c lines are the ones that hurt: the line is dropped without any message.
WinuxCmd 1.2.3 (WinuxCmd-1.2.3-win-x64.tar.gz) and 1.2.1, Windows 11.
The issue was drafted with Claude and the reproductions were run on the versions above.
Activity
caomengxuan666 commentedon Nov 28, 2026
队长分拣:确认本方 bug(存量问题,非新回归;建议 P2)。
队长在 X299 装机 WinuxCmd 1.2.1 上实跑全部复现(与报告人的 1.2.3 结论一致,1.2.1 同坏);GNU 侧为云端 oracle(grep 3.12 / sed 4.9,LC_ALL=C.UTF-8;CJK 区间例另以 en_US.UTF-8 复核,GNU 得 aXb):
grep -ao '可[^:]*'(od)e5 8f af e5 bc 80 3d 54(可开=T)e5 8f af e5(可 + 开的首字节)grep -c '可[^:]*='grep -c '^[^x]$'(输入 开)grep -c '^[^x][^x][^x]$'(输入 开)grep -ao '[:]'(od)ef 0a bc 0a 9a 0a(三个单字节匹配)sed 's/[^:]*/X/'(开:x)X:xX+ 坏字节 +:xsed 's/[一-龥]/X/g'(a中b)aXbaXXXb(中 的三个字节各替换一次).不受影响(^.$两侧均 1),与报告一致。定性:winux-regex 的括号类是字节集合——否定类在多字节字符的首个被排除字节处截断、肯定类逐字节命中。修复方向:类匹配改为按字符(UTF-8 解码)求值,至少覆盖否定类与多字节端点区间。与 #1910(量词只绑末字节)、#1909(-i 仅 ASCII 折叠)同属 winux-regex 字节化根因,建议同波处理。
— 队长分拣
Merge origin/main into fix/winux-regex-multibyte-chars