#!/bin/sh # dirclean -- clean up after emacs, framemaker, TeX, and dvi tools # # SYNOPSIS: run eclean, fclean, and texclean -d # # AUTHOR: Gary T. Leavens USAGE="Usage: $0 [prefix ...]" [ -n "$echo" ] && set -x # eclean -- clean up emacs backup files # # SYNOPSIS: Remove files whose names match *~ and *.bak from # the current working directory. # Giving prefixes causes only files with names starting in that list # to be removed. eclean() { USAGE="Usage: $0 [prefix ...]" # no options allowed case "$1" in -*) echo "$USAGE" >&2 exit 2 ;; esac # all files if no prefix specified if test $# -eq 0 then set '*' fi # remove the files for p do rm -f ${p}~ ${p}.bak done } # fclean -- clean up framemaker backup files # # SYNOPSIS: Remove files whose names match *.backup from # current working directory # Giving prefixes causes only files with names starting in that list # to be removed. fclean() { USAGE="Usage: $0 [prefix ...]" # no options allowed case "$1" in -*) echo "$USAGE" >&2 exit 2 ;; esac # all files if no prefix specified if test $# -eq 0 then set '*' fi # remove the files for p do rm -f ${p}.backup.fm done } # texclean -- clean up after tex # # SYNOPSIS: Remove *.log, *.blg, *.dvi-err, *.ilg output files. # Giving prefixes causes only files with names starting in that list # to be removed. # If the -d option is given, removes the *.dvi-alw and *.dvi files also. # If the -f option is given, removes the *.aux, *.bbl *.glo *.idx *.ind # *.lof *.lot and *.toc files also (but not *.dvi and *.dvi-alw files) texclean() { USAGE="Usage: $0 [-f] [-d] [prefix ...]" DEFAULTrms='log blg dvi-err ilg' DVIrms='dvi dvi-alw' ALLrms='aux dvi bbl glo idx lof lot toc ind' SUFFIXES="$DEFAULTrms" # check usage and set SUFFIXES to -f flag while test `expr X"$1" : X'-.*'` -gt 1 do case "$1" in -f) SUFFIXES="$SUFFIXES $ALLrms" shift ;; -d) SUFFIXES="$SUFFIXES $DVIrms" shift ;; -fd|-df) SUFFIXES="$SUFFIXES $ALLrms $DVIrms" shift ;; -?) echo "$USAGE" >&2 exit 2 ;; -) shift break ;; esac done # all files if no prefix specified if test $# -eq 0 then set '*' fi # remove the files for p do for s in $SUFFIXES do rm -f ${p}.${s} done done } # no options allowed case "$1" in -*) echo "$USAGE" >&2 exit 2 ;; esac eclean "$@" texclean -d "$@" fclean "$@"