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