Files
mercury/tools/cleanint
Zoltan Somogyi f65c4a5253 Rewrite this script to handle nested modules better.
Estimated hours taken: 0.5
Branches: main

tools/cleanint:
	Rewrite this script to handle nested modules better.
2002-05-11 16:38:17 +00:00

53 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
#
# Check whether there are any Mercury-compiler generated files in this
# directory that do not belong to Mercury modules in this directory.
# Report their names.
#
# The script assumes that the source for a module mod1.mod2.mod3 is stored
# in a file whose name is either fully qualified (e.g. mod1.mod2.mod3.m),
# or not qualified at all (e.g. mod3.m).
prefix=
while getopts p: flag
do
case $flag in
p) prefix="$OPTARG/"
;;
*) echo "usage: cleanint [-p prefix]"
exit 1
;;
esac
done
shift `expr $OPTIND - 1`
if test $# -gt 0
then
echo "usage: cleanint [-p prefix]"
exit 1
fi
for suffix in d dep int int2 int3 date date3 opt optdate trans_opt trans_opt_date err
do
for file in *.$suffix
do
# If there are no files with a given suffix,
# then avoid the ill-formed call to basename.
if test -f "$file"
then
base=`basename $file .$suffix`
if test ! -f "$base.m"
then
basebase=`echo $base | sed -e 's/.*\.//'`
if test ! -f "$basebase.m"
then
echo $prefix$file
fi
fi
fi
done
done
exit 0