ShellCheck, a static analysis tool for shell scripts
Go to file
Michael Orlitzky 1be0f1ea75 Add a pre-sdist hook to compile the man page (Github issue #247).
This replaces the default preSDist hook in Setup.hs with our own. The
only thing the new hook does is compile the man page using callCommand
from System.Process.

If Pandoc fails, the entire sdist process will fail, since
Extra-Source-Files in the cabal file now lists the man page.

This is preferable to a build hook, because Pandoc pulls in a huge
number of dependencies. It's better to build the man page once and
ship it than to require every user to build and install pandoc before
he can build ShellCheck.

This creates another TODO item: an install hook can now be used to
install the man page along with the rest of ShellCheck. But beware,
the "man path" can vary from system to system.
2015-01-24 12:15:36 -05:00
ShellCheck Fix pattern matching error in z=$(echo) 2015-01-02 18:06:10 -08:00
test Test Suite in Cabal (cabal test) 2014-05-31 01:30:23 +00:00
.gitignore Using a more complete Haskell .gitignore 2014-05-30 00:10:21 +00:00
LICENSE Added readme and licenses 2012-11-16 19:43:05 -08:00
README.md Removed Arch from readme, added Debian. 2014-10-12 17:13:35 -07:00
Setup.hs Add a pre-sdist hook to compile the man page (Github issue #247). 2015-01-24 12:15:36 -05:00
ShellCheck.cabal Add a pre-sdist hook to compile the man page (Github issue #247). 2015-01-24 12:15:36 -05:00
shellcheck.1.md Warn about missing shebangs. 2014-08-09 17:32:42 -07:00
shellcheck.hs Don't crash on empty files with -f gcc. 2014-09-23 10:11:15 -07:00

README.md

ShellCheck - A shell script static analysis tool

http://www.shellcheck.net

Copyright 2012-2014, Vidar 'koala_man' Holen Licensed under the GNU Affero General Public License, v3

The goals of ShellCheck are:

  • To point out and clarify typical beginner's syntax issues, that causes a shell to give cryptic error messages.

  • To point out and clarify typical intermediate level semantic problems, that causes a shell to behave strangely and counter-intuitively.

  • To point out subtle caveats, corner cases and pitfalls, that may cause an advanced user's otherwise working script to fail under future circumstances.

ShellCheck is written in Haskell, and requires 2 GB of memory to compile.

Installing

On systems with Cabal:

cabal update
cabal install shellcheck

On Debian based distros:

apt-get install shellcheck

On OS X with homebrew:

brew install shellcheck

ShellCheck is also available as an online service:

http://www.shellcheck.net

Building with Cabal

This sections describes how to build ShellCheck from a source directory.

First, make sure cabal is installed. On Debian based distros:

apt-get install cabal-install

On Fedora:

yum install cabal-install

On Mac OS X with homebrew (http://brew.sh/):

brew install cabal-install

On Mac OS X with MacPorts (http://www.macports.org/):

port install hs-cabal-install

Let cabal update itself, in case your distro version is outdated:

$ cabal update
$ cabal install cabal-install

With cabal installed, cd to the ShellCheck source directory and:

$ cabal install

This will install ShellCheck to your ~/.cabal/bin directory.

Add the directory to your PATH (for bash, add this to your ~/.bashrc file):

export PATH=$HOME/.cabal/bin:$PATH

Verify that your PATH is set up correctly:

$ which shellcheck
~/.cabal/bin/shellcheck

Running tests

To run the unit test suite:

cabal configure --enable-tests
cabal build
cabal test

Happy ShellChecking!