Repository navigation
fix(builtins): #859 — pushd -n with no operand is a silent no-op (rc 0), not the swap arm - #889
Conversation
…0), not the swap arm GNU pushd.def:290-291: the option walk consumes `-n` and leaves `list == 0`, reaching `return (EXECUTION_SUCCESS)` — a silent no-op. The bare-`pushd` swap arm (pushd.def:195-213) only runs when the list is empty with NO options consumed, and errors "no other directory" when the stack is short. rubash collapsed both empty-list forms into Swap, so `pushd -n` reported "no other directory" rc 1. parse_pushd_operand now distinguishes them: options consumed + no operand -> PushdOperand::NoOp (silent rc 0); no options at all -> Swap. popd note: the second half of #859 ("fresh popd -N silent rc 1") does not reproduce — WSL GNU 5.3.0 prints "popd: directory stack empty" rc 1 for `popd -0`/`-5`/`+0` on a fresh stack (pushd_error offset==0 -> builtin_error, pushd.def:390-394 -> 540-546), byte-identical to rubash's current output. No divergence there; only pushd -n needed the fix. Verified byte-for-byte vs WSL GNU 5.3.0 across pushd -n (empty + live stack), dirs state, and fresh popd ±N faces. Regression test pushd_no_cd_with_no_operand_is_a_silent_noop added; dirstack family (844/848/830/509) stays green.
|
欢迎!这是你的第一个 PR 🎉 请确认已跑过本地测试套件;CI 通过后维护者会 review。 |
独立评审:APPROVE-WITH-NITS(含 #855 CR 预言闭环确认)评审方式:fetch #855 CR 预言闭环:已闭环master(base)上
实现上 票面②(fresh
|
Closes #859 (the reproducible half).
pushd -nwith no operand — GNU pushd.def:290-291: the option walk consumes-nand leaveslist == 0, so the builtin returnsEXECUTION_SUCCESSsilently. The bare-pushdswap arm (:195-213,"no other directory") only runs when the list is empty with no options consumed. rubash collapsed both empty-list forms into Swap, sopushd -nerrored rc 1.parse_pushd_operandnow distinguishes them via a newPushdOperand::NoOp.popd -Nfresh-stack — does NOT reproduce as described. WSL GNU 5.3.0 printspopd: directory stack emptyrc 1 forpopd -0/popd -5/popd +0on a fresh stack (pushd_erroroffset==0 →builtin_error, pushd.def:390-394 → 540-546). That is byte-identical to rubash's current output, so there is no divergence to fix. If the issue meant a different operand shape (e.g.popd -nalone, or a non-fresh stack), I can re-probe — but every±Nform on an empty stack reports the diagnostic in GNU.Byte-for-byte verified vs WSL GNU 5.3.0 (
pushd -non empty and live stacks, dirs state, freshpopd ±Nfaces). New regressionpushd_no_cd_with_no_operand_is_a_silent_noop; dirstack family (844/848/830/509) stays green.