Admin/check_ml_headers
author wenzelm
Sun, 09 Oct 2011 17:06:19 +0200
changeset 45993 d53036e77ef3
parent 37740 763feb2abb0d
permissions -rwxr-xr-x
Added tag Isabelle2011-1 for changeset 76fef3e57004
     1 #!/usr/bin/env bash
     2 #
     3 # check_ml_headers - check headers of *.ML files in distribution for inconsistencies
     4 #
     5 # requires some GNU tools
     6 #
     7 
     8 ONLY_FILENAMES=""
     9 if [ "$1" == "-o" ]
    10 then
    11   ONLY_FILENAMES=1
    12 fi
    13 
    14 REPORT_EMPTY=""
    15 if [ "$2" == "-e" ]
    16 then
    17   REPORT_EMPTY=1
    18 fi
    19 
    20 ISABELLE_SRC="$(isabelle getenv -b ISABELLE_HOME)/src/"
    21 
    22 for LOC in $(find "$ISABELLE_SRC" -name "*.ML")
    23 do
    24   TITLE="$(head -n 1 "$LOC" | grep -Po '(?<=Title:)\s*\S+.ML' | grep -Po '\S+.ML')"
    25   FILELOC="${LOC:${#ISABELLE_SRC}}"
    26   if [ "$TITLE" != "$FILELOC" ]
    27   then
    28     if [ -n "$TITLE" -o \( -n "$REPORT_EMPTY" -a $(basename "$FILELOC") != "ROOT.ML" \) ]
    29     then
    30       if [ -z "$ONLY_FILENAMES" ]
    31       then
    32         echo "Inconsistency in $LOC: $TITLE"
    33       else
    34         echo "$LOC"
    35       fi
    36     fi
    37   fi
    38 done