#!/bin/sh if [ $# -eq 0 ] || [ "$1" = "-h" ]; then cat</dev/null 2>&1; then echo >&2 "'indent' not found in PATH. Exiting." exit 1 fi CMD="indent -i4 -ppi4 -bli0 -cli4 -nut" _formatc_dir() { ## Note that '+' does not work together with {} concatenation. Don't know ## why... find "$1" -type f \ -name "*.[ch]" \ -print \ -exec $CMD {} \; \ -exec rm {}"~" \; } for i ; do [ ! -e "$i" ] && continue if [ -d "$i" ]; then _formatc_dir "$i" else $CMD "$i" rm -f "$i~" fi done