Repository navigation
WIP: fix(stty): size/speed output-style queries, -a promotion, rows/cols validation (#1430) - #1431
Merged
Merged
Conversation
…1430) `stty size` was listed as a known no-argument setting, so the apply path accepted it silently: on a real console it printed nothing and returned 0, where GNU prints "<rows> <cols>". `stty speed` had the same shape. Both are output-style requests in GNU stty: extract them from the settings list (a value setting's argument is data, never a request), reject combinations with mode settings or a second output style, and answer them from the target device handle: - size prints the visible geometry from GetConsoleScreenBufferInfo on the stdin/-F handle (never stdout, so `stty size > file` works), and fails with an error when the geometry cannot be obtained - never an empty success. - speed prints the nominal 38400 the -a listing claims. - -a now prints the real rows/columns instead of hardcoded 50/120. Also for #1430: promote -a/--all/-g/--save tokens that arrive in the positional list through a forwarding layer (GNU getopt never delivers a registered option as an operand; `stty -a` was rejected with "invalid argument '-a'") and validate that integer value settings (rows/cols/columns/line/min/time/ispeed/ospeed) actually receive an integer, so `stty rows abc` is diagnosed instead of silently accepted. Help text updated for size/speed; zh-CN catalog synced in winuxcmd-i18n (command.stty.description) with a VERSION bump.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1430
三症状根因(均为 src/commands/stty.cpp)
stty size空输出 rc=0:size被放进is_known_noarg_setting当 apply-mode 无参 setting,apply_setting走到兜底分支返回 true——整条查询路径不存在,静默成功。speed同形(GNU 里同为输出型请求)。另外-a输出里的rows 50; columns 120是硬编码假几何。stty -a被拒 "invalid argument '-a'":框架解析层对已注册的-a本可正确解析,但经转发层以 positional 形态到达时,build_config把它当 setting 送进validate_settings拒收。GNU getopt 永不把已注册选项当操作数交付——到达 positional 的输出型旗标仍应按其本义生效。stty rows 40 cols 120值形式被拒:值形式在验证层须完整对齐 GNU 文法;同时整数型值设置(rows/cols/columns/line/min/time/ispeed/ospeed)此前不校验值本身,stty rows abc会被静默接受。修法
size/speed从 setting 名单摘除,新增extract_query_settings把两者从设置列表中按输出型请求提取(值设置的参数是数据、永不匹配,如stty intr size的 CHAR);与 mode 设置或第二个输出型并用时沿用既有两条 GNU 式互斥/冲突报错。size查询走目标句柄(stdin 或 -F 设备句柄,从不查 stdout,故stty size > file成立)上的GetConsoleScreenBufferInfo可见窗口几何,打印 " ";取不到几何时带 Win32 错误文本非零退出——绝不空输出 rc=0。-a的 rows/columns 同源改真值。speed打印 -a 列表所称的名义值 38400(控制台无波特率)。build_config提升以 positional 形态到达的-a/--all/-g/--save为旗标(与 GNU 的选项置换语义一致)。validate_settings对整数型值设置校验值为十进制整数,否则按既有 "invalid argument ''" 形状报错。测试与验证分层
stty size > file文件内容应为 "30 120";stty -a输出 rows/columns 与窗口实际几何一致;经 niubash 宿主调用stty -a不再报 invalid argument;stty rows 40 cols 120rc=0(Windows 侧语义为校验后接受,几何由宿主拥有,不承诺改窗——与帮助中既有口径一致)。I18N 同步(AGENTS.md 强制)
帮助文本变更(新增 size 行、speed 去掉"(accepted only)"、结尾注记补 size/speed):英文目录已用
scripts/i18n_batch.py extract重新生成核对;zh-CN 目录在 winuxcmd-i18n 仓同步command.stty.description并 bump VERSION 0.6.21 → 0.6.22(单独 PR)。i18n_batch.py validate报告的其余 key 漂移(cmp/hexdump/join/ls/patch/legacy.* 等)为两仓既存增量漂移,与 stty 无关,未在本批处理;stty 键集两边一致。