#!/bin/sh # See LICENSE file for copyright and license details. type="$1" shift 1 e="$(printf '\033\n')" pattern1='define[[:space:]]\{1,\}\(__kernel_\)\{0,1\}'"$type"'[[:space:]]' pattern2='typedef[[:space:]].*[[:space:]]\(__kernel_\)\{0,1\}'"$type"'\([^A-Za-z0-9_]\|$\)' pattern='\('"${pattern1}"'\|'"${pattern2}"'\)' find "$@" | while read f; do if test -L "$f" || test -d "$f"; then continue fi fe="$(printf '%s\n' "$f" | sed 's/\([\[*.]\|\/\|\]\)/\\&/g')" sed -n '/^.*'"$pattern.*"'$/p' < "$f" \ | sed 's/\(__kernel_\)\{0,1\}'"$type/$e"'[1;31m&'"$e"'[m/g' \ | sed "s/^/$e[35m$fe$e[m /" done