Repository navigation
fix #896: pushd dash family follows GNU option walk - #901
Conversation
Root cause: parse_pushd_operand treated a leading `--` as an ordinary options skip and `-` as a malformed number, and mapped option-only argument lists to the no-argument swap. GNU spec (third_party/bash, 5.3 patch 15): - pushd.def:183-190 leading `--` sets skipopt, skips the walk entirely; the rest goes verbatim to cd_builtin (orig_list). - pushd.def:214-260 walk: `-n` (NOCD), `--` (break, rest verbatim), lone `-` (break as Dir operand), else break. - pushd.def:288 list==0 after the walk is silent EXECUTION_SUCCESS. - pushd.def:298 Dir path delegates to cd_builtin; cd.def:326-330 CD_COMPLAINS (config-top.h) rejects multi-word lists with `too many arguments` (no usage), mapped to EXECUTION_FAILURE (:310-315). - Lone `-` is `cd -`: cd.def:339-349 OLDPWD arm, LCD_PRINTPATH echo of the raw value on success only (:371-374). Behavior (all probed byte-identical vs WSL GNU bash 5.3.0 script files): - `pushd -- -n` -> `pushd: -n: No such file` rc 1 (was usage rc 2). - `pushd -` -> OLDPWD echo + stack rc 0; unset OLDPWD -> `OLDPWD not set` rc 1; empty OLDPWD -> empty echo + no-op success rc 0. - `pushd -n` / `pushd -n --` alone -> silent rc 0 (was swap). - `pushd /tmp extra`, `pushd -- -n extra`, `pushd - -n`, `pushd "" extra` -> `pushd: too many arguments` rc 1, no usage. - `pushd -n -- +1` pushes a literal `+1`; `pushd -- +1`/`-- --` are cd failures; `pushd --` alone still swaps. Tests: tests/issue896_pushd_dashes_regressions.rs (9 tests); re-verified issue509 (3), issue754 (11/12, one pre-existing ls-missing env failure), issue830 (9), issue844_848 (12), executor part_025 (12/13, one pre-existing PWD-case env failure). Follow-up (out of scope, same walk, pre-existing): `pushd +1 -n` should be a silent NOCD rotation and `pushd +1 +9` an inline range error - the walk currently stops at the first +/-N operand.
|
欢迎!这是你的第一个 PR 🎉 请确认已跑过本地测试套件;CI 通过后维护者会 review。 |
独立评审结论:APPROVE(独立评审代理,自建 worktree @ 971cfd3 + 53997eb 两分支复核;oracle = WSL GNU bash 5.3.0(1) 票面两形(#896)——双侧逐字节一致
对照 vendored bash-5.3 源核过语义:leading 矩阵 34 形——stdout 全等,stderr 18/18 消息体全等(仅沙箱根路径掩码)覆盖: 回归
已知预存(非本 PR 引入,commit message 已注 follow-up)
非阻塞观察:Dir 路径(含新 结论:APPROVE,不合入(留维护者操作)。 |
Fixes #896 (from #889 CR).
Leading
--now sets skipopt (pushd.def:183-190), lone-iscd $OLDPWD(pushd.def:223-225, cd.def:339-349), option-only lists are silent no-ops (pushd.def:288), and multi-word Dir operands aretoo many argumentsrc 1 via CD_COMPLAINS (cd.def:326-330, config-top.h).Full matrix probed byte-identical vs WSL GNU bash 5.3.0 script files. New tests/issue896_pushd_dashes_regressions.rs (9 tests); issue509/830/844_848 green; issue754 and executor part_025 each have one pre-existing env failure (missing
lsbinary / PWD drive-case).Follow-up noted in commit message: walk-past-+-N (
pushd +1 -nsilent NOCD rotation,pushd +1 +9inline range error) stays pre-existing behavior.