./tools/check-style.sh fails on stock OS X currently; this fixes it:
- use pipes directly rather than exec redirection (macOS's ancient
version of bash fails with the latter)
- macOS's ancient bash doesn't support '\e' escapes in `echo -e`;
replace with \033 instead
- BSD grep doesn't support GREP_COLORS, but does allow GREP_COLOR.
Adding both doesn't hurt GNU grep: GREP_COLOR is deprecated, and won't
be used when GREP_COLORS is set.
- BSD grep doesn't collapse multiple /'s in the listed filename, so
failures under `include/` would should up as
`include//pybind11/whatever.h`. This removes the / from the include
directory argument.
Minor other changes:
- The CRLF detection runs with -l, so GREP_COLORS wasn't doing
anything; removed it.
- The trailing whitespace test would trigger on CRLFs, but the CR would
result in messed up output. Changed the test to just match trailing
spaces and tabs, rather than all whitespace.
This makes the output considerably easier to use: it now highlights (in
red) matched tabs (instead of just listing the filenames), and adds
line numbers to both the tabs check and the space-less if check outputs.
The check-style exit status wasn't being propagated properly because
the loops were running in a subshell (and so the change the the
`errors` variable wasn't in the active command shell). This fixes it
by running the greps in subshells and the loops in the main shell.
This also avoids the if(/for(/while( style check on
tests/CMakeLists.txt, since it *does* have if() statements with no space
that are producing error messages, but that is (acceptable) CMake style.
This adds a tool that checks style (currently just for tabs instead of
spaces in files under include/tests/docs) and produces a travis-ci build
failure if any problems are found.