bash -n
is a basic but useful builtin syntax linter.
If you do not use the pre-commit
Python command & hook manager (check it out, it's great!), you can define a git
pre-commit hook "manually" by putting the following in a file at .git/hooks/pre-commit
:
#!/bin/sh
# Redirect output to stderr:
exec 1>&2
echo "Executing bash native syntax linter on all modified .sh files:"
if ! git diff --cached --name-only --diff-filter=AM HEAD | grep '.sh$' | xargs -n 1 bash -n
then
echo "Error : syntax issues were detected"
exit 1
fi
First, lets mention Git Bash (aka msysgit) : the old version was a PITA to extend with additional packages (e.g. adding common C libs like libxml), and the new one (renamed Git for Windows), is based on MSYS2, but does not include a package manager.
Hence, we were left with …
I'd like to introduce you to an awesome git companion : pre-commit
hooks by Yelp.
Git hooks are scripts that git
executes before or after events such as: commit, push, and receive.
Git hooks are a built-in feature, but git
does not offer much support for them: if there is a …