isdn4linux/do_indent

67 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
INDENT=`which indent`
SED=`which sed`
if test "$INDENT" = "" ; then
echo programm indent missing
exit
fi
if test "$SED" = "" ; then
echo programm sed missing
exit
fi
BACKUP=false
CHECK=false
case "$1" in
-b)
BACKUP=true
shift
;;
-c)
CHECK=true
BACKUP=false
shift
;;
esac
formatiere() {
if $CHECK ; then
OUT=$1.idout
else
OUT=$1
fi
cp $1 $1\~
cat $1\~ | $INDENT -kr -i8 -cli8 -psl -lp | \
$SED -e 's/^ / /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/^\( \+\) /\1 /g' \
-e 's/[ ]\+$//g' > $OUT
if $CHECK ; then
diff -u $1\~ $OUT
rm $OUT
fi
if ! $BACKUP ; then
rm $1\~
fi
}
for f in $* ; do
formatiere $f
done