A few months back I wrote a post on how to compile and build an installer for the shellcheck binary for macOS.
Just a few weeks later, the shellcheck project added a download for a pre-compiled binary for macOS. You can now download the binary with this link:
https://shellcheck.storage.googleapis.com/shellcheck-latest.darwin.x86_64.tar.xz
Ironically, macOS can unarchive xz archives when you double click them in the Finder, but there is no command line tool on macOS to unarchive them. In the previous post, I ran into the same problem, and there you can find instructions on how to install thexz
tools on macOS.Update 2020-03-26: I was unnecessarily complicating this. You can use
tar
to unarchive this:tar -xf shellcheck-latest.darwin.x86_64.tar.xz
After downloading and un-archiving, you can manually move the shellcheck
binary to a suitable directory. The standard location is /usr/local/bin
.
For manual installations, this is it! Much simpler than before. Thank you!
Note: if you want the man page as well, you still need to build it with pandoc from the source.
Build a pkg for managed deployment
If you are a MacAdmin and want to distribute shellcheck
with your management system, you will need to build an installer package (pkg).
Instead of copying the binary to /usr/local/bin
, place it in a payload
folder in a project folder. Then build the pkg with pkgbuild
:
% mkdir -p ShellcheckPkg/payload
% cp ~/Downloads/shellcheck-latest/shellcheck ShellcheckPkg/payload
% pkgbuild --root ShellcheckPkg/payload --identifier com.example.shellcheck --version 0.7.0 --install-location /usr/local/bin shellcheck-0.7.0.pkg
Replace the 0.7.0
with the actual version number.
Automated Package creation with autopkg
And because all of this isn’t really that difficult, I built autopkg
recipes for Shellcheck You can find them in my recipe repository or with autopkg search shellcheck
. Enjoy!