Properly print warnings to stderr. Also, use : instead of 'echo' as a
fallback as the latter spits out garbage to stdout.
Examples without pep8 installed.
Before:
$ ./hooks/pre-commit
./hooks/pre-commit: line 97: WARNING:: command not found
ERROR: pep8 tests failed!
After:
$ ./hooks/pre-commit
WARNING: pep8 is not installed, using dummy placeholder!
PEP8_IGNORE="E123,E501,W503"
err() {
- echo ERROR: "$@"
+ echo >&2 ERROR: "$@"
exit 1
}
warn() {
- echo WARNING: "$@"
+ echo >&2 WARNING: "$@"
}
cmd_exists() {
fi
done
warn "$1 is not installed, using dummy placeholder!"
- echo -n echo
+ echo -n :
}
PYFLAKES=$(find_command pyflakes)