Repository navigation
Description
Summary
A batch of builtin flag / semantics divergences from GNU. Item 1 is the sharpest and I re-verified it myself; items 2–5 are verified here too; the table at the end is the rest of the sweep, agent-verified but not re-checked by me, listed so they can be split out.
Same method throughout: LF script files, ni u (installed 1.4.0, rubash git e785c3c8f610) vs WSL GNU bash 5.3.0, stdout and stderr captured to separate files, byte/count claims decided by python outside the code under test.
1. unset NAME also removes a function of the same name — re-verified
foo=bar
foo(){ echo FUNC; }
unset foo
echo "var=[${foo-<unset>}]"
type -t foo >/dev/null 2>&1 && echo "func=still-there" || echo "func=gone"| variable | function | |
|---|---|---|
| GNU bash | unset | still-there |
| niu / rubash | unset | gone |
GNU's unset without -f/-v removes the variable, and only falls back to the function when no variable of that name exists (builtins/set.def). Here the function disappears as well, silently. A script that does cfg=...; cfg(){ ...; }; … unset cfg loses its function and nothing reports it. Sharpest item in the batch — may be worth its own issue.
2. dirs -l prints one entry per line — re-verified
niu: dirs -l → three lines, one path each
dirs → one line, space-separated
GNU: dirs -l → one line, space-separated (same shape as `dirs`)
cat -A confirms the newlines. Any read -r a b c <<< "$(dirs -l)"-style consumer gets a different field count.
3. shift with a bad operand exits 1 — re-verified
( set -- 1 2; shift x ) 2>/dev/null; echo $? # niu 1 GNU 2
( set -- 1 2; shift 1 2 ) 2>/dev/null; echo $? # niu 1 GNU 24. Three builtins exist here that bash does not have — re-verified
niu: command -v setopt → setopt
command -v unsetopt → unsetopt
GNU: (neither) (the only hit is the external /usr/bin/sudo)
enable -a line count: 64 (niu) vs 61 (GNU). So setopt and unsetopt are in the builtin table. A script that probes for them to decide "am I under zsh or bash" gets the wrong answer under niu.
(Positive result: the 61 real bash builtin names all agree — command -v / type -t / enable -a match GNU. Nothing is missing.)
Rest of the sweep — agent-verified, not re-checked by me
| id | builtin | form | niu | GNU |
|---|---|---|---|---|
| B19 | exec | exec -a NAME cmd |
argv[0] unchanged | argv[0] = NAME |
| B03 | read | read -n/-N with \ in input |
backslash counts toward N | counts emitted chars |
| B01 | printf | %b containing \c |
rc 1 | rc 0 |
| B02 | printf | printf -v with no name |
error, no usage | error + usage |
| B06 | declare | declare -p -f on an attributed fn |
omits declare -fx FN |
prints it |
| B07 | readonly | readonly -p -f FN |
prints body + declare -fr |
prints nothing |
| B08 | hash | hash fn (fn is a function) |
not found, rc 1 |
silent, rc 0 |
| B09 | hash | hash -l NAME (operand) |
prints entry | prints nothing |
| B10 | hash | hash -- NAME |
invalid option, rc 2 |
accepted, rc 0 |
| B12 | pushd | pushd a b |
pushd: a: No such file |
pushd: too many arguments |
| B13 | pushd | pushd -n <absent> |
validates and fails rc 1 | stores literally, rc 0 |
| B14 | source | source DIR |
DIR: No such file |
source: DIR: is a directory |
| B17 | let | let with no args |
message without trailing newline | message + \n |
| B18 | shift | (see item 3 above) | rc 1 | rc 2 |
| B20 | enable | enable -p NAME |
enables NAME / errors | prints a reusable list, rc 0 |
| B21 | enable | enable -Z |
rubash: prefix, no usage, rc 1 |
SCRIPT: line N: + usage, rc 2 |
| B04 | umask | umask -- |
invalid option, rc 2 |
prints the mask, rc 0 |
B19 I could not reproduce in my form — with exec -a RENAMED "$BASH" show.sh both shells report $0 as the script name, which is correct for a script file; the sweep's form must differ, so treat B19 as reported-only.
B15/B16 (the eval, let and (( … )) diagnostics ignoring an fd-2 redirection) are not filed here — they are additional emitters for #726, and are noted there.
Ruled out by the sweep as non-bugs (recorded so nobody re-derives them)
test -L/-hon symlinks:ln -sfails withOperation not permittedon Windows, so no symlink exists to test.-nt/-ot/-ef: an earlier diff was DrvFs 1-second mtime granularity; re-probed with asleep 2gap → byte-identical.type -a/command -vpath strings,ulimit -avalues,compgen -A user/group/hostname,times,help -m: host environment, not semantics.enable -f foo.so: nodlopenon Windows.
Method
LF .sh probes written with a file, run as niu <file>; oracle WSL GNU bash 5.3.0 entered through a tr -d '\r' copy; a marker asserted in both arms so a broken arm cannot read as a difference; stdout/stderr to separate files; byte claims by python.
Activity
caomengxuan666 commentedon Oct 17, 2026
Correction — item 1 is a duplicate of a closed issue, already fixed, and already has a regression test
My apologies for the noise. Item 1 (
unset NAMEalso removing a same-named function) is #645, which is closed, and the fix is not in the build I measured:So the fix landed two days after the build I tested, and it came with its own regression test. Item 1 should be treated as fixed on HEAD, verified by your
issue645_unset_function_regressions.rs— please close/ignore that part of this issue, and I will re-run the whole case set against a near-HEAD build rather than report from a three-day-old release again.Two other items also need re-labelling
shiftwith a bad operand, rc 1 vs 2) is a leftover, not a new finding. The closed [builtins] dirstack 族数字参数验证退出码错:dirs/popd/pushd 非数字 → rc=1,dirs -l +q 静默 rc=0(GNU 统一 2) #509 is the same class for the dirstack family ("dirs/popd/pushd 非数字 → rc=1,GNU 统一 2").pushd a b(item B12) andpushd -n <absent>(B13) are in that same family. So items 3, B12 and B13 are best read as [builtins] dirstack 族数字参数验证退出码错:dirs/popd/pushd 非数字 → rc=1,dirs -l +q 静默 rc=0(GNU 统一 2) #509 leftovers rather than three new builtin bugs.read -n/-Ncounting the backslash (B03) probably belongs under your open read -n/-N: limit counts transport units, splitting the last kept carrier pair #714 ("read -n/-N: limit counts transport units, splitting the last kept carrier pair") — same surface, both about what gets counted. Filed here only because I could not confirm the mechanism is identical; please fold it in if it is.What is genuinely new here
From the duplicate sweep:
setopt/unsetopt,promptvars, andcompgen -A signalreturned no other issue in the tracker, so items 4 (setopt/unsetoptin the builtin table), B11 (dirs -lshape) and the rest of the table appear to be new.Method note for anything from me from now on
Every finding I filed up to #759 was measured against
e785c3c8(2026-10-14). Anything fixed after that date will look broken in my reports. Going forward I will re-run against a build from the currentmasterand state the commit in the issue, the way the invocation sweep already did (it separated "installed only" from "persists atea9c18e8").[-]builtin divergences: unset NAME also deletes a same-named function (plus dirs -l shape, shift status, 3 non-bash builtins, and 17 more)[/-][+]builtin divergences: `dirs -l` shape, `shift` bad-operand status, 3 non-bash builtins (setopt/unsetopt), and 17 more[/+]fix(builtins): command -v any-found status, dirs -l separator (#704 R…
caomengxuan666 commentedon Oct 17, 2026
先处理了第 1、2、3 项,提交
5da6421。项 1
unset连函数一起删 —— 当前 master 已不复现应该是这期间别的提交带掉的(issue 记录的基线是
e785c3c8)。这条可以划掉。项 2
dirs -l逐行 —— 已修-l被当成-p处理了。-l是 long form,只影响$HOME折不折成~,分隔符仍是单个空格;只有-p(以及本来就逐行的-v)才一个一行。rubash 的栈本来就存全路径,所以-l根本没有单独渲染,不该置printable。dirs/usr /tmp(一行)dirs -l/usr /tmp(一行)dirs -pdirs -vdirs -l -vdirs -v相同回归测试
dirs_long_form_keeps_the_space_separator。项 3
shift坏操作数状态 —— 在 5.2.21 上与 GNU 一致,暂不动issue 里记的是 GNU 5.3.0 给 2。我这边沙箱 GNU 是 5.2.21,实测:
两边一致,所以在你记录的 5.3.0 基线上可能是版本行为变化。需要一份 5.3.0 的输出再定,暂时不改(改了反而会和 5.2.21 分叉)。
项 4
setopt/unsetopt—— 没动这两个是 zsh 名字,但从
builtin_direct_command.rs看是有意加的(execute_zsh_option_builtin),删掉会动到现有行为。这是产品决策,等你定:要么删掉让"是不是 bash"的探测正确,要么保留并写进文档说明是 niubash 扩展。表格里其余 17 项
没动。等这批单点清完再按需拆。
fix(builtins,prompt): #759 builtin divergences (shift usage status, z…
test(regression): re-record errors.snap shift usage-status bytes (#759 …
test(shift): split the #759 pin by framing — GNU folds the surplus-op…