I want to call ShellCheck, a Haskell program for linting shell scripts, from a Makefile
.
When I install ShellCheck via cabal install
, it is installed as ~/.cabal/bin/shellcheck
. So, I have configured Bash accordingly:
$ cat ~/.bashrc
export PATH="$PATH:~/.cabal/bin"
$ source ~/.bashrc
$ shellcheck -V
ShellCheck - shell script analysis tool
version: 0.3.4
license: GNU Affero General Public License, version 3
website: http://www.shellcheck.net
This enables me to run shellcheck
from any directory in Bash. However, when I try to call it from a Makefile, make
cannot find shellcheck
.
$ cat Makefile
shlint:
-shlint lib/
shellcheck:
-shellcheck lib/**
lint: shlint shellcheck
$ make shellcheck
shellcheck lib/**
/bin/sh: 1: shellcheck: not found
make: [shellcheck] Error 127 (ignored)
I think that make is not receiving the same PATH
as my normal Bash shell. How can I fix this?