Skip to content

Fix #1621: un-register retired echo -r/--repeat so it prints as data - #1624

Merged
caomengxuan666 merged 2 commits into
mainfrom
fix/1621-echo-repeat-is-data
Nov 14, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
fix/1621-echo-repeat-is-data

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #1620 (residual O2): echo -r x and bare echo -r returned rc 1 on the new exe, while GNU coreutils 9.4 prints them as data, rc 0.

Root cause

ECHO_OPTIONS in src/commands/echo.cpp still declared the retired -r/--repeat extension as INT_TYPE. The generic dispatcher (src/core/opt.cppm) int-parses an INT_TYPE option's value before the handler runs: echo -r x failed the int parse (set_invalid_argument), bare echo -r hit set_missing_argument, both rc 1. The rust2 echo handler (rust2/crates/winux-cmds/src/echo.rs) is GNU-exact and would have printed the tokens as data.

Correction to the issue text, verified by measurement on base: the long form was already data on base. Echo's policy sets allow_long_options = false (command_context.cppm), so the long-option branch (opt.cppm:404) is skipped and --repeat x falls through to positional. Only the two short spellings were actually rejected on base. The --repeat x pin guards the already-correct behavior.

Fix

  • Remove -r/--repeat from ECHO_OPTIONS (keep -u/--upper registered: a Bool flag can never reject an argv; it only parses for occurrence bookkeeping).
  • Sync the echo permissive-policy comment in src/core/command_context.cppm.
  • Add three regression pins in tests/unit/echo/echo_unit_test.cpp: -r x, -r, --repeat x → data, rc 0.
  • I18N: the fix removes exactly one catalog key, command.echo.option.repeat (verified with scripts/i18n_batch.py extract — present in the base extract, absent in the head extract); the zh-CN catalog sync is i18n(zh-CN): drop command.echo.option.repeat (WinuxCmd#1621) winuxcmd-i18n#37 (key removed + VERSION 0.6.32 → 0.6.33).

GNU anchors

  • builtins/echo.def (bash 5.3): echo has no -r option.
  • coreutils 9.4 /usr/bin/echo: echo -r x → -r x, echo -r → -r, echo --repeat x → --repeat x, all rc 0.

本 PR 删除了什么

  • src/commands/echo.cpp: the -r/--repeat entry (one OPTION(...) line + its [EXT] comment line) from ECHO_OPTIONS. No other code removed.
  • catalogs/zh-CN/catalog.json (winuxcmd-i18n, separate PR Merge develop into main #37): the command.echo.option.repeat key (one line).
  • Nothing else deleted: no command, no file, no test removed; the echo --repeat 3 hello example line is untouched (it demonstrates a data spelling, consistent with GNU output).

Verification (X299 + CI, 2026-11-14)

UNVERIFIED-BY-CAPTAIN — legs run by the fix lane; captain review pending.

The retired -r/--repeat extension was still declared INT_TYPE in
ECHO_OPTIONS, so the dispatcher consumed and int-validated its value
ahead of the handler: `echo -r x` and bare `echo -r` were rejected
with rc 1 while GNU coreutils 9.4 prints them as data, rc 0. The
long form was already data (echo allows no long options), so removing
the registration makes every spelling reach the handler verbatim like
every other non-[-neE] token. Sync the permissive-policy comment in
command_context.cppm and add regression pins for the three spellings
from the issue.

Refs #1621
@caomengxuan666

Copy link
Copy Markdown
Member Author

i18n-drift root cause fixed at the source: the un-registration removed command.echo.option.repeat from the English extraction, leaving an orphan zh-CN extra key. Dropped in unixwin/winuxcmd-i18n#38 (merged to main), so fresh checks clone a clean catalog — no baseline change needed on this PR (198 recorded items, none new). Verified locally: drift exit 0, 9/9 GNU byte-parity probes, ctest #818-821 green.

The i18n-drift orphan-key fix landed on the catalog repo's main
(#38); the PR-trigger workflow has no ready_for_review trigger, so
this empty commit re-runs the check suite against the fixed catalog.
caomengxuan666 added a commit that referenced this pull request Nov 14, 2026
…historical snapshot (#1629)

The checkpoint section records the acceptance state as audited by the
lead review: current main had 50 commands wired (not the historical
76/42 numbers), A1/tail/ABI-v3 are not accepted yet, I18N is an
acceptance prerequisite, and the safety record for preserve-root
(chmod/chgrp/chown) blocks wiring until the listed gates pass.

Captain addendum records same-day movement: #1627 merged, PRs
#1624/#1625/#1626/#1628 open, and the fix/batch-1595-1616-1617 trio.
@caomengxuan666
caomengxuan666 merged commit 48273dc into main Nov 14, 2026
11 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member Author

队长合入后复核 PASS — WinuxCmd#1624(Fixes #1621)

已合入 48273dc3。在合并树的新鲜构建上复核(注意:worktree 里的旧 usr/bin/echo.exe 是硬链接旧映像,必须重建 winuxcmd 后 wpm links rebuild 才能测到本修复):

  • echo -r x → -r x,rc 0
  • echo -r → -r,rc 0
  • echo --repeat x → --repeat x,rc 0
  • echo --repeat 3 hi → --repeat 3 hi,rc 0(仍按数据打印,和 GNU 一致)
  • echo -u hi → -u hi,rc 0(-u 保留注册、永不拒绝 argv,符合正文)
  • --gtest_filter=echo.* → 36/36

i18n:源码里 command.echo.option.repeat 已随 -r/--repeat 注销消失;i18n-drift 在本树 CI 为 SUCCESS,依赖的 winuxcmd-i18n#38 已并入主线,未改 baseline —— 与正文一致。修复方向(把 INT_TYPE 的 -r/--repeat 从选项表拿掉,而不是在 handler 里特判)也符合“根因在注册面”的结论。

无删除面异议:只删了一个已退役扩展选项及其注释,示例 echo --repeat 3 hello 保留且语义仍是数据。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant