How do I syntax check a Bash script without running it?

前端 未结 8 679
渐次进展
渐次进展 2020-11-28 00:16

Is it possible to check a bash script syntax without executing it?

Using Perl, I can run perl -c \'script name\'. Is there any equivalent command for ba

8条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 00:58

    Time changes everything. Here is a web site which provide online syntax checking for shell script.

    I found it is very powerful detecting common errors.

    enter image description here

    About ShellCheck

    ShellCheck is a static analysis and linting tool for sh/bash scripts. It's mainly focused on handling typical beginner and intermediate level syntax errors and pitfalls where the shell just gives a cryptic error message or strange behavior, but it also reports on a few more advanced issues where corner cases can cause delayed failures.

    Haskell source code is available on GitHub!

提交回复
热议问题