Skip to content

docs(2.0): applet inventory scan for library-form command set (#1488 step 1) - #1545

Merged
caomengxuan666 merged 1 commit into
mainfrom
docs/2.0-inventory
Nov 9, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
docs/2.0-inventory

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #1488 (第一步:清点扫描). Scan-only change — no source code touched.

What

Headline numbers

  • IO idiom: pure win32-console 79 · mixed 94 (61 touch std::cin/cout/cerr, 35 CRT stdio, 36 direct GetStdHandle/ReadFile/WriteFile) · no-IO 3 (true/false/sync) · read_all_stdin 1 (envsubst). Output is fully converged on the console layer for all 176.
  • exit_usage: 172/176 none; kill/nice/timeout/top use TerminateProcess (process-control semantics).
  • oracle_status (逐命令对照 Oracle 源码审计:全命令面行为契约核验与修复(用户 2026-10-31 令) #1462 audit reports): clean 52 · notes 78 · deviates 33 · no-oracle 7 · unreviewed 6 (arch/locale/pinky/pwd/stdbuf/who).
  • coverage: unit+differential 100 · unit 74 · differential-only 1 (whereis) · none 1 (w).
  • replace_wave: 1=15, 2=68, 3=64, 4=29.
  • Hardest five: find (5578 loc), grep (3096), sed (2802), top (1551), less (1187).
  • Wave-1 shortlist (15): true, false, test, [, basename, dirname, printenv, pwd, mkdir, rmdir, readlink, realpath, chmod, chown, df.

Verification

Spot-checked 7 scanned commands against source (df, hostname, tr, cat, kill, sync, mkfifo): 1 scanner regex gap (safeErrorPrint without Ln suffix) found and fixed; 7/7 consistent post-fix.

Scan-only inventory of all 176 REGISTER_COMMAND applets for the 2.0
library-form command set (Refs #1488): per-applet loc, io_idiom,
global_state, exit_usage, oracle_status (#1462 audit reports),
test_coverage (tests/unit + differential corpus), replace_wave.

Findings: output converged on the Win32 console layer for all 176
(79 pure-safePrint, 94 mixed, 3 no-IO); 172/176 have no exit/abort
direct calls; wave1 = 15 lowest-risk replacements (true, false, test,
[, basename, dirname, printenv, pwd, mkdir, rmdir, readlink, realpath,
chmod, chown, df). Spot-check 7 commands, 1 scanner regex gap fixed
(safeErrorPrint without Ln suffix), 7/7 consistent post-fix.
@caomengxuan666
caomengxuan666 merged commit a92ba5e into main Nov 9, 2026
8 of 9 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 9, 2026
…f/who) (#1547)

# gap-fill: w 测试补齐 + 6 命令 #1462 式 oracle 审计(arch/locale/pinky/pwd/stdbuf/who)

独立 worktree 分支。方法按 #1462:oracle 源码/活 oracle 先行,再裁决,再修复。全部对照 WSL GNU oracle(coreutils 9.4、procps-ng 4.0.4、glibc 2.39),脚本文件形态,stdout/stderr/exit 三向对照。

## Task 1 — w(唯一无测试的已审计命令)

- 新增 `tests/unit/w`(13 枚 session-count-independent pin):header 存在/-h 抑制、-s tail、-f toggle、-i force-FROM、-p/-o 接受、无匹配 user 过滤恰留 2 行 header 且 exit 0、非法选项诊断 + exit 1、--help/--version。
- WSL procps-ng 4.0.4 差分门:可比面 exit code 与首行诊断逐字节一致。
- 记录残余(不改):header 与上游 procps-ng v4.0.4 git 源码一致(src/w.c:799-806,67/45 列);Ubuntu 构建的 4.0.4 oracle 印 68/46——发行版补丁 vs git tag;上游源码仍为合同。
- 附带:修 C4477(time_ival7 中 `%02d` 配 `long long` 参数的错误转换)。

## Task 2 — 6 份审计(`tests/differential/audit-<cmd>.md`)

| 命令 | 结论 | 一句话 |
| --- | --- | --- |
| arch | **clean** | 全部面逐字节一致(除仓库级 quotearg/help 约定) |
| pwd | **clean** | -L/-P last-wins、POSIXLY_CORRECT 存在性测试、PWD 校验回退全部一致 |
| stdbuf | **clean** | 全矩阵,含 optstring-'+' 操作数边界、bare-K xstrtol 规则、125/127 退出码 |
| locale | **notes**(4 处修复) | bare -c/-k 改静默(并删一段破损字面量拼接块)、未知名白名单 `locale: unknown name "X"`、编造名(codeset/month/…)被拒 + `mon` 加入、-k print_item 引号 |
| pinky | **notes**(3 处修复) | -l 补 try-help 行、`--lookup` 被拒(9.4 无此长选项)、When 列 `%b %e`;heading 在 LC_ALL=C 下逐字节一致 |
| who | **notes**(3 处修复) | 缺 FILE 操作数静默 exit 0(旧 pin 与 oracle 矛盾,已翻转)、双 `who: who:` 前缀修复、时间面切 C-locale 12 列分支(who.c:803-811) |

平台面按 W4 协调裁决维持(mesg、utmp 视图、WTS 行、locale 仿真模型),各在审计文件内引用。locale 值模型重做(C-locale 空表/-a/-m 清单/分类转储)需 locale-database 仿真层(niu #758 依赖),已在审计文件内记录为后续跟进。

## 验证

- Debug 构建绿(scripts/build-with-vs.ps1,pcre2 preset)。
- 触及命令单测 89/89 绿(`w.* locale.* pinky.* who.* pwd.* stdbuf.* arch.*`)。
- CI 全套:3830/3830 通过(x64 default,`[ctest-gate] all tests passed`);队长复核确认:baseline 红腿为主干既有 WSL 侧进程杀死基建红(与 #1540 同族,main 同签名复现);i18n-drift 红腿为本 PR 孤儿 key(删 --lookup 选项 + locale 值表提取口径)——合入前须先在 winuxcmd-i18n 仓同步 PR 清掉并 bump VERSION(或本 PR 内 `--update-baseline` 记录),见文末复核注。
- 净行:+886/−159,15 文件(4 src + 7 audit md + 4 单测),零 arch/pwd/stdbuf 产品改动。

## 本 PR 删除了什么

- `pinky --lookup` 长选项一个(GNU 9.4 无此选项,属编造项;删后 `--lookup` 按 GNU 措辞被拒,exit 1)。
- locale 旧 `-k` 无参分支整段破损输出(含字面量拼接块 `LC_CTYPE= + get_system_locale() + ` 等 6 行)与旧 `month`/`codeset`/`collate`/`ctype`/`monetary`/`numeric`/`time`/`default_language` 编造名应答。
- who 对缺失 FILE 操作数的 `No such file or directory` 报错(旧 pin 一并翻转)。
- locale 旧报错措辞 `locale: unknown keyword 'X'`(改为 GNU 的 `locale: unknown name "X"`)。
- 其余皆为新增(测试、审计记录、白名单表),无产品功能删除。

Refs #1488, #1462, #1545

---
复核注(队长复核员):i18n 同步提交落地前本稿不适用;同步落地后重核 C2 门脚本 rc=0 与正文删除节即可合入。
复核记录:~/workspace/review-1547/CAPTAIN-VERIFY.md
@caomengxuan666
caomengxuan666 deleted the docs/2.0-inventory branch November 18, 2026 05:50
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