bin/isabelle
author wenzelm
Wed Dec 04 13:06:30 1996 +0100 (1996-12-04)
changeset 2308 641be5ad47af
parent 2292 c1c5652600f1
child 2343 2588b63b42ca
permissions -rwxr-xr-x
improved 'not found' messages;
     1 #!/bin/bash
     2 #
     3 # $Id$
     4 #
     5 # Basic Isabelle startup script.
     6 
     7 
     8 ## settings
     9 
    10 ISABELLE_HOME=$(dirname $(dirname $0))
    11 . $ISABELLE_HOME/lib/scripts/getsettings
    12 
    13 #get bash-style platform info
    14 unset HOSTTYPE
    15 unset OSTYPE
    16 PLATFORM=$(bash -noprofile -c 'echo $HOSTTYPE-$OSTYPE')
    17 
    18 
    19 ## diagnostics
    20 
    21 PRG=$(basename $0)
    22 
    23 function usage()
    24 {
    25   echo
    26   echo "Usage: $PRG [OPTIONS] [INPUT] [OUTPUT]"
    27   echo
    28   echo "  Options are:"
    29   echo "    -c           force copying of heap file"
    30   echo "    -e MLTEXT    pass MLTEXT to ML session"
    31 #FIXME  echo "    -o OPTIONS   pass options to ML system"
    32   echo "    -q           non-interactive session"
    33   echo "    -r           open heap file read-only"
    34   echo "    -u           pass 'use\"ROOT.ML\" handle _ => exit 1; commit();'"
    35   echo "                 to the ML session"
    36   echo
    37   echo "  INPUT (default \"$DEFAULT_LOGIC\") and OUTPUT specify in/out heaps."
    38   echo "  These are either names to be searched in the Isabelle path, or actual"
    39   echo "  file names (containing at least one /)."
    40   echo "  If INPUT is \"SYSTEM\", just start the bare bones ML system."
    41   echo
    42   exit 1
    43 }
    44 
    45 function fail()
    46 {
    47   echo "$1"
    48   exit 2
    49 }
    50 
    51 
    52 ## process command line
    53 
    54 # options
    55 
    56 COPYDB=""
    57 MLTEXT=""
    58 COPYDB=""
    59 OPTIONS=""
    60 TERMINATE=""
    61 READONLY=""
    62 
    63 while getopts "ce:qru" OPT
    64 do
    65   case "$OPT" in
    66     c)
    67       COPYDB=true
    68       ;;
    69     e)
    70       MLTEXT="$MLTEXT $OPTARG"
    71       ;;
    72     o)
    73       OPTIONS="$OPTIONS $OPTARG"
    74       ;;
    75     q)
    76       TERMINATE=true
    77       ;;
    78     r)
    79       READONLY=true
    80       ;;
    81     u)
    82       MLTEXT="$MLTEXT use\"ROOT.ML\" handle _ => exit 1; commit();"
    83       ;;
    84     \?)
    85       usage
    86       ;;
    87   esac
    88 done
    89 
    90 shift $(($OPTIND - 1))
    91 
    92 
    93 # args
    94 
    95 INPUT=""
    96 OUTPUT=""
    97 
    98 if [ $# -ge 1 ]; then
    99   INPUT="$1"
   100   shift
   101 fi
   102 
   103 if [ $# -ge 1 ]; then
   104   OUTPUT="$1"
   105   shift
   106 fi
   107 
   108 [ $# -ne 0 ] && fail "Bad args: $*"
   109 
   110 
   111 ## check ML system
   112 
   113 [ -z "$ML_SYSTEM" ] && fail "Missing ML system settings! Unable to run Isabelle."
   114 
   115 
   116 ## input heap file
   117 
   118 [ -z "$INPUT" ] && INPUT="$DEFAULT_LOGIC"
   119 
   120 case "$INPUT" in
   121   SYSTEM)
   122     INFILE=""
   123     ;;
   124   */*)
   125     INFILE="$INPUT"
   126     [ ! -f "$INFILE" ] && fail "Bad heap file file: \"$INFILE\""
   127     ;;
   128   *)
   129     ISA_PATH=""
   130     INFILE=""
   131     for DIR in $(echo $ISABELLE_PATH | tr : " ")
   132     do
   133       ISA_PATH="$ISA_PATH $DIR/$ML_SYSTEM-$PLATFORM"
   134       [ -z "$INFILE" -a -f $DIR/$ML_SYSTEM-$PLATFORM/$INPUT ] && INFILE=$DIR/$ML_SYSTEM-$PLATFORM/$INPUT
   135     done
   136     if [ -z "$INFILE" ]; then
   137       echo "Unknown logic \"$INPUT\" -- no heap file found in:"
   138       for DIR in $ISA_PATH
   139       do
   140         echo "  $DIR"
   141       done
   142       exit 2
   143     fi
   144     ;;
   145 esac
   146 
   147 
   148 ## output heap file
   149 
   150 case "$OUTPUT" in
   151   "")
   152     [ -z "$READONLY" -a -w "$INFILE" ] && OUTFILE="$INFILE"
   153     ;;
   154   */*)
   155     OUTFILE="$OUTPUT"
   156     ;;
   157   *)
   158     OUTDIR="$ISABELLE_OUTPUT/$ML_SYSTEM-$PLATFORM"
   159     mkdir -p "$OUTDIR"
   160     OUTFILE="$OUTDIR/$OUTPUT"
   161     ;;
   162 esac
   163 
   164 
   165 ## run it!
   166 
   167 ML_SYSTEM_BASE=$(echo $ML_SYSTEM | cut -f1 -d-)
   168 
   169 export INFILE OUTFILE COPYDB MLTEXT OPTIONS TERMINATE
   170 [ -f $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM ] && exec $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM
   171 exec $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM_BASE