Repository navigation
[1417] feat(gfsh): 完整实现 type 内置命令并支持 -afptP 选项 - #104
Merged
Merged
Conversation
此前 type --help 被当成短选项逐字符解析,遇到第二个 - 后报 "gfsh: type: --: invalid option" 并以退出码 2 失败,与 bash 约定不符。 按 bash 内建约定(CASE_HELPOPT):--help 打印长帮助到 stdout 并返回 0; -h 因 h 不在 [-afptP] 中仍按无效选项报错(退出码 2),与真实 bash 一致。 新增 type --help / type --help cd 的单元测试。
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.
变更内容
在
gfsh中完整实现type内置命令:-t:仅输出类型(builtin、keyword、file);未找到时静默且退出码 1。-p:仅在目标解析为文件时输出可执行文件路径;内建/关键字不输出但返回 0;未找到返回 1。-P:强制在PATH中搜索外部文件(忽略关键字与内建命令);未找到外部文件返回 1。-a:列出全部位置(支持与-t、-p组合)。--结束选项解析;未知选项提示并返回退出码 2。if、for、while等)与内建命令(cd、echo、type等)。/或\\的路径跳过关键字和内建匹配直接检查可执行权限。PATHEXT)搜索PATH目录下的可执行文件。eval.scm中内建分派type,支持输出重定向及退出码透传,以及命令替换内存捕获。parser.scm对命令参数位置保留关键字的词法解析限制。eval-type-test.scm单元测试及集成测试,通过gf check与gf fmt。