调试 shell 脚本:语法检查而不执行

Dan*_*iel 9 bash shell-script testing

是否有一些选项我可以只检查 [bash] shell 脚本的语法来检查它的语法,但实际上不执行任何操作也不会造成任何潜在的损害?

Mic*_*zek 7

bash(1)手册页:

-n      Read commands but do not execute them. This may be used to check a
        shell script for syntax errors. This is ignored by interactive shells.
Run Code Online (Sandbox Code Playgroud)