lib/Tools/update_header
changeset 58872 f0f623005324
child 62446 5b749c31eb97
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/lib/Tools/update_header	Sun Nov 02 16:47:45 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     1.4 +#!/usr/bin/env bash
     1.5 +#
     1.6 +# Author: Makarius
     1.7 +#
     1.8 +# DESCRIPTION: replace obsolete theory header command
     1.9 +
    1.10 +
    1.11 +## diagnostics
    1.12 +
    1.13 +PRG="$(basename "$0")"
    1.14 +
    1.15 +function usage()
    1.16 +{
    1.17 +  echo
    1.18 +  echo "Usage: isabelle $PRG [FILES|DIRS...]"
    1.19 +  echo
    1.20 +  echo "  Options are:"
    1.21 +  echo "    -s COMMAND   alternative heading command (default 'section')"
    1.22 +  echo
    1.23 +  echo "  Recursively find .thy files and replace obsolete theory header commands"
    1.24 +  echo "  by 'section' (default), or 'chapter', 'subsection', 'subsubsection'."
    1.25 +  echo
    1.26 +  echo "  Old versions of files are preserved by appending \"~~\"."
    1.27 +  echo
    1.28 +  exit 1
    1.29 +}
    1.30 +
    1.31 +
    1.32 +## process command line
    1.33 +
    1.34 +#options
    1.35 +
    1.36 +SECTION="section"
    1.37 +
    1.38 +while getopts "s:" OPT
    1.39 +do
    1.40 +  case "$OPT" in
    1.41 +    s)
    1.42 +      SECTION="$OPTARG"
    1.43 +      ;;
    1.44 +    \?)
    1.45 +      usage
    1.46 +      ;;
    1.47 +  esac
    1.48 +done
    1.49 +
    1.50 +shift $(($OPTIND - 1))
    1.51 +
    1.52 +
    1.53 +# args
    1.54 +
    1.55 +[ "$#" -eq 0 -o "$1" = "-?" ] && usage
    1.56 +
    1.57 +SPECS="$@"; shift "$#"
    1.58 +
    1.59 +
    1.60 +## main
    1.61 +
    1.62 +find $SPECS -name \*.thy -print0 | \
    1.63 +  xargs -0 "$ISABELLE_TOOL" java isabelle.Update_Header "$SECTION"