blob: c5ad5f74ad2388e2e3e4773730f9cd100392bfff [file] [log] [blame]
Jason Rhinelanderac427892016-08-28 13:00:44 -04001#!/bin/bash
2#
3# Script to check include/test code for common pybind11 code style errors.
4# Currently just checks for tabs used instead of spaces.
5#
6# Invoke as: tools/check-style.sh
7#
8
Jason Rhinelanderdbc4bf62016-08-28 14:53:04 -04009errors=0
10IFS=$'\n'
11found=
12grep $'\t' include/ tests/ docs/*.rst -rl | while read f; do
13 if [ -z "$found" ]; then
Jason Rhinelanderac427892016-08-28 13:00:44 -040014 echo -e '\e[31m\e[01mError: found tabs instead of spaces in the following files:\e[0m'
15 found=1
Jason Rhinelanderdbc4bf62016-08-28 14:53:04 -040016 errors=1
Jason Rhinelanderac427892016-08-28 13:00:44 -040017 fi
18
19 echo " $f"
20done
21
Jason Rhinelanderdbc4bf62016-08-28 14:53:04 -040022found=
23grep '\<\(if\|for\|while\)(' include/ tests/* -r --color=always | while read line; do
24 if [ -z "$found" ]; then
25 echo -e '\e[31m\e[01mError: found the following coding style problems:\e[0m'
26 found=1
27 errors=1
28 fi
29
30 echo " $line"
31done
32
33exit $errors