32.6k star,后悔没有早点知道这个开源工具–shellcheck
1 shellcheck 简介
今天发现的一款神器,如果你日常会接触到shell脚本,或者说自己需要写一些shell脚本,那么强烈建议你用下这个工具。
shellcheck一个静态的shell脚本分析工具,可以判断脚本哪里有异常,哪里可以优化,并且会给出对应的解决办法。几年前我咋没发现这个,后悔。。。
一个简单的示例:
这款工具不仅适用于初学者,对于中高级使用者帮助更大。
2 安装
github可以访问的直接到如下链接去下载就可以,目前支持多个终端,也有web可访问
https://github.com/koalaman/shellcheck
github如果无法访问的话,可以后台直接私信
web访问地址:
https://www.shellcheck.net/
使用方式:
3 shell脚本中的一些常见错误
- 常见错误引用
- 常见错误条件语句
- 误用的命令
- 初学者常见错误