#!/bin/sh RE='[a-z]+\(\) {' if grep -Eq "$RE" "$@"; then echo 'Functions with no argument without explicit "void" parameter:' >&2 grep -En "$RE" "$@" exit 1 fi awk ' /^[a-zA-Z0-9_]+.+{$/ && !/^static / { match($0, /[a-zA-Z0-9_]+\(/) fn_name = substr($0, RSTART, RLENGTH - 1) if (fn_name != "main") { header = substr(FILENAME, 0, length(FILENAME) - 1) "h" if (system("grep -qF \"" fn_name "(\" " header)) { print "non-static function is not declared in a header:" printf "%s:%s:%s\n", FILENAME, FNR, $0 exit 1 } } } ' "$@"