SuperAPI AI 工具集

x-is

通用与其它

查看项目

更新于 10-16 05:48

技能介绍

用途:x is 用于在 Shell 脚本中校验值或环境状态是否满足条件,支持批量检查,结果通过退出码表达(0 成功、1 失败),便于搭配 &&/|| 串联逻辑,且校验时不输出内容。

前提:使用前需加载 x-cmd,命令为 . ~/.x-cmd.root/X。

主要能力:类型检查(int、float、positive、negative)、区间检查(minmax)、比较(eq、within、in 及 in-、in_、in/、in| 分隔列表)、网络(ip)、文件(newest、oldest,支持 glob)、变量(unset)、环境检测(interactive、interactive_tty、interactiveshell、repl、stdout2tty、wsl、cygwin、msys、gitbash、termux、ish)、适用性判断(suitable_pkg、suitable_advise_env、suitable_advise_repl)。

使用方式示例:x is int 42 100 -5;x is float 3.14;x is minmax 1 100 50 75;x is ip 192.168.1.1;x is newest target src/*.c;x is unset VAR1 VAR2;x is interactive;x is wsl;x is termux;x is suitable_pkg。批量检查时所有值均需通过。

适用场景:脚本前置检查、环境条件分支、文件重建判断、临时变量清理验证等。

限制:需先加载 x-cmd;float 必须含小数点;批量检查要求全部通过;文档未提供更多限制与平台细节。