/usr/bin/wfindent is in findent 2.7.3-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #!/bin/sh
# $Id: wfindent.tmpl 145 2016-11-13 16:16:33Z willem_vermin $
# vim: filetype=sh
#
# in-place indenting of fortran sources using findent
# example:
# wfindent -i4 *.f90
#
# A check is made if the output file has the same number of lines
# as the input file.
# Only if this check succeeds, the file is overwritten,
# otherwize an error message is printed.
#
# the location of findent, replace with correct location:
FINDENT="/usr/bin/findent"
if ! "$FINDENT" -v >/dev/null 2>&1 ; then
FINDENT="findent" # try if findent is in PATH
if ! "$FINDENT" -v >/dev/null 2>&1 ; then
echo "$0: findent not found, exiting"
exit 1
fi
fi
echo "$0 using: "`"$FINDENT" -v`
parms=$( getopt -o a:b:c:C:d:e:E:f:F:hHi:I:j:k:l:L:m:o:qr:R:s:t:vw:x: -- "$@" )
if [ $? -ne 0 ] ; then
exit 1
fi
eval set -- "$parms"
fparms=""
while [ "$1" ] ; do
case "$1" in
--) shift
break
;;
*) if [ "$1" = "-v" ] ; then
echo "wfindent using $FINDENT"
"$FINDENT" -v
echo "wfindent: indented files: 0"
exit $?
fi
case "$1" in
"-h"|"-H") "$FINDENT" "$1"
exit $?
;;
esac
if [ "$1" != "-q" ] ; then
fparms="$fparms $1"
else
echo "wfindent: ignored flag -q"
echo " use $FINDENT -q < filename"
fi
shift
;;
esac
done
tmp=`mktemp`
n=0
while [ "$1" ] ; do
if [ -e "$1" ] ; then
norig=`wc -l < "$1"`
# Check if file ends with newline. If not: correct number of lines
lastchar="$(tail -c1 "$1" | od -a -An | tr -d ' ')"
if [ "$lastchar" != "nl" ] ; then
norig=`expr $norig + 1`
fi
cat "$1" | "$FINDENT" $fparms > $tmp
nnew=`wc -l < $tmp`
if [ $norig -eq $nnew ] ; then
cp $tmp "$1"
n=`expr $n + 1`
else
echo "***** wfindent: error while converting $1, conversion abandoned"
fi
fi
shift
done
echo "wfindent: indented files: $n"
rm $tmp
|