lib/Tools/update_header
author wenzelm
Fri Jan 01 16:40:47 2016 +0100 (2016-01-01)
changeset 62028 2ecee4679f99
parent 58872 f0f623005324
child 62446 5b749c31eb97
permissions -rwxr-xr-x
updated for release;
wenzelm@58872
     1
#!/usr/bin/env bash
wenzelm@58872
     2
#
wenzelm@58872
     3
# Author: Makarius
wenzelm@58872
     4
#
wenzelm@58872
     5
# DESCRIPTION: replace obsolete theory header command
wenzelm@58872
     6
wenzelm@58872
     7
wenzelm@58872
     8
## diagnostics
wenzelm@58872
     9
wenzelm@58872
    10
PRG="$(basename "$0")"
wenzelm@58872
    11
wenzelm@58872
    12
function usage()
wenzelm@58872
    13
{
wenzelm@58872
    14
  echo
wenzelm@58872
    15
  echo "Usage: isabelle $PRG [FILES|DIRS...]"
wenzelm@58872
    16
  echo
wenzelm@58872
    17
  echo "  Options are:"
wenzelm@58872
    18
  echo "    -s COMMAND   alternative heading command (default 'section')"
wenzelm@58872
    19
  echo
wenzelm@58872
    20
  echo "  Recursively find .thy files and replace obsolete theory header commands"
wenzelm@58872
    21
  echo "  by 'section' (default), or 'chapter', 'subsection', 'subsubsection'."
wenzelm@58872
    22
  echo
wenzelm@58872
    23
  echo "  Old versions of files are preserved by appending \"~~\"."
wenzelm@58872
    24
  echo
wenzelm@58872
    25
  exit 1
wenzelm@58872
    26
}
wenzelm@58872
    27
wenzelm@58872
    28
wenzelm@58872
    29
## process command line
wenzelm@58872
    30
wenzelm@58872
    31
#options
wenzelm@58872
    32
wenzelm@58872
    33
SECTION="section"
wenzelm@58872
    34
wenzelm@58872
    35
while getopts "s:" OPT
wenzelm@58872
    36
do
wenzelm@58872
    37
  case "$OPT" in
wenzelm@58872
    38
    s)
wenzelm@58872
    39
      SECTION="$OPTARG"
wenzelm@58872
    40
      ;;
wenzelm@58872
    41
    \?)
wenzelm@58872
    42
      usage
wenzelm@58872
    43
      ;;
wenzelm@58872
    44
  esac
wenzelm@58872
    45
done
wenzelm@58872
    46
wenzelm@58872
    47
shift $(($OPTIND - 1))
wenzelm@58872
    48
wenzelm@58872
    49
wenzelm@58872
    50
# args
wenzelm@58872
    51
wenzelm@58872
    52
[ "$#" -eq 0 -o "$1" = "-?" ] && usage
wenzelm@58872
    53
wenzelm@58872
    54
SPECS="$@"; shift "$#"
wenzelm@58872
    55
wenzelm@58872
    56
wenzelm@58872
    57
## main
wenzelm@58872
    58
wenzelm@58872
    59
find $SPECS -name \*.thy -print0 | \
wenzelm@58872
    60
  xargs -0 "$ISABELLE_TOOL" java isabelle.Update_Header "$SECTION"