linux - 如何在不运行 Bash 脚本的情况下对其进行语法检查?

是否可以在不执行的情况下检查 bash 脚本语法?

使用 Perl,我可以运行 perl -c 'script name'。 bash 脚本是否有任何等效命令?

最佳答案

bash -n scriptname

也许有一个明显的警告:这会验证语法,但不会检查您的 bash 脚本是否尝试执行不在您的路径中的命令,例如 ech hello 而不是 echo hello .

https://stackoverflow.com/questions/171924/

相关文章:

python - Pandas 索引列标题或名称

python - 初始化 dict : curly brace literals {} or the

python - 为什么很多例子在 Matplotlib/pyplot/python 中使用 `fi

linux - 我在哪里可以设置 crontab 将使用的环境变量?

python - 删除具有重复索引的 pandas 行

python - 将 matplotlib 图例移到轴外使其被图形框截断

python - 如何提高我的爪子检测能力?

linux - 如何将密码传递给scp?

linux - 在 Ubuntu 中创建目录的符号链接(symbolic link)

linux - 如何找出给定用户的组?