bin/isabelle
author wenzelm
Mon, 03 Nov 1997 12:13:18 +0100
changeset 4089 96fba19bcbe2
parent 3502 ec22ba0a26ec
child 4333 1d326b826851
permissions -rwxr-xr-x
isatool fixclasimp;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3203
af42c8cc8e75 fixed bash path!!!
wenzelm
parents: 3184
diff changeset
     1
#!/bin/bash
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
2704
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    10
PRG=$(basename $0)
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    11
2735
29434f9b95dd even more robust and user friendly invocation (no longer requieres
wenzelm
parents: 2711
diff changeset
    12
ISABELLE_HOME=$(dirname $0)/..
29434f9b95dd even more robust and user friendly invocation (no longer requieres
wenzelm
parents: 2711
diff changeset
    13
. $ISABELLE_HOME/lib/scripts/getsettings || \
2936
bd33e7aae062 fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents: 2768
diff changeset
    14
  { echo "$PRG probably not called from its original place!"; exit 2; }
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    15
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    16
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    17
## diagnostics
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:"
2343
2588b63b42ca added -norc option;
wenzelm
parents: 2308
diff changeset
    25
  echo "    -e MLTEXT    pass MLTEXT to the ML session"
2704
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    26
  echo "    -m MODE      add print mode for output"
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"
3502
ec22ba0a26ec added -w option;
wenzelm
parents: 3203
diff changeset
    29
  echo "    -w           reset write permissions on OUTPUT"
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    30
  echo
3184
4e0bbfb113d5 renamed DEFAULT_LOGIC to ISABELLE_LOGIC;
wenzelm
parents: 3183
diff changeset
    31
  echo "  INPUT (default \"$ISABELLE_LOGIC\") and OUTPUT specify in/out heaps."
2292
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 /)."
2768
bc6d915b8019 renamed SYSTEM to RAW_ML_SYSTEM;
wenzelm
parents: 2735
diff changeset
    34
  echo "  If INPUT is \"RAW_ML_SYSTEM\", just start the bare bones ML system."
2292
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
MLTEXT=""
2704
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    51
MODES=""
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    52
TERMINATE=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    53
READONLY=""
3502
ec22ba0a26ec added -w option;
wenzelm
parents: 3203
diff changeset
    54
NOWRITE=""
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    55
3502
ec22ba0a26ec added -w option;
wenzelm
parents: 3203
diff changeset
    56
while getopts "e:m:qrw" OPT
2292
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
    e)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    60
      MLTEXT="$MLTEXT $OPTARG"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    61
      ;;
2704
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    62
    m)
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    63
      if [ -z "$MODES" ]; then
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    64
        MODES="\"$OPTARG\""
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    65
      else
2711
098f9ce0541a fixed -m order;
wenzelm
parents: 2704
diff changeset
    66
        MODES="\"$OPTARG\", $MODES"
2704
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    67
      fi
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    68
      ;;
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    69
    q)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    70
      TERMINATE=true
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    71
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    72
    r)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    73
      READONLY=true
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    74
      ;;
3502
ec22ba0a26ec added -w option;
wenzelm
parents: 3203
diff changeset
    75
    w)
ec22ba0a26ec added -w option;
wenzelm
parents: 3203
diff changeset
    76
      NOWRITE=true
ec22ba0a26ec added -w option;
wenzelm
parents: 3203
diff changeset
    77
      ;;
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    78
    \?)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    79
      usage
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    80
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    81
  esac
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    82
done
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    83
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    84
shift $(($OPTIND - 1))
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    85
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    86
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    87
# args
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    88
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    89
INPUT=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    90
OUTPUT=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    91
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    92
if [ $# -ge 1 ]; then
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    93
  INPUT="$1"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    94
  shift
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    95
fi
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    96
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    97
if [ $# -ge 1 ]; then
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    98
  OUTPUT="$1"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    99
  shift
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   100
fi
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   101
2936
bd33e7aae062 fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents: 2768
diff changeset
   102
[ $# -ne 0 ] && { echo "Bad args: $*"; usage; }
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   103
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   104
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   105
## check ML system
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   106
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   107
[ -z "$ML_SYSTEM" ] && fail "Missing ML system settings! Unable to run Isabelle."
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   108
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   109
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   110
## input heap file
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   111
3184
4e0bbfb113d5 renamed DEFAULT_LOGIC to ISABELLE_LOGIC;
wenzelm
parents: 3183
diff changeset
   112
[ -z "$INPUT" ] && INPUT="$ISABELLE_LOGIC"
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   113
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   114
case "$INPUT" in
2768
bc6d915b8019 renamed SYSTEM to RAW_ML_SYSTEM;
wenzelm
parents: 2735
diff changeset
   115
  RAW_ML_SYSTEM)
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   116
    INFILE=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   117
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   118
  */*)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   119
    INFILE="$INPUT"
2343
2588b63b42ca added -norc option;
wenzelm
parents: 2308
diff changeset
   120
    [ ! -f "$INFILE" ] && fail "Bad heap file: \"$INFILE\""
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   121
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   122
  *)
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   123
    ISA_PATH=""
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   124
    INFILE=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   125
    for DIR in $(echo $ISABELLE_PATH | tr : " ")
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   126
    do
2968
8ba30b031f31 eliminated PLATFORM;
wenzelm
parents: 2936
diff changeset
   127
      ISA_PATH="$ISA_PATH $DIR"
8ba30b031f31 eliminated PLATFORM;
wenzelm
parents: 2936
diff changeset
   128
      [ -z "$INFILE" -a -f $DIR/$INPUT ] && INFILE=$DIR/$INPUT
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   129
    done
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   130
    if [ -z "$INFILE" ]; then
2343
2588b63b42ca added -norc option;
wenzelm
parents: 2308
diff changeset
   131
      echo "Unknown logic \"$INPUT\" -- no heap file found in:" >&2
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   132
      for DIR in $ISA_PATH
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   133
      do
2343
2588b63b42ca added -norc option;
wenzelm
parents: 2308
diff changeset
   134
        echo "  $DIR" >&2
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   135
      done
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   136
      exit 2
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   137
    fi
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   138
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   139
esac
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   140
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   141
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   142
## output heap file
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   143
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   144
case "$OUTPUT" in
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   145
  "")
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   146
    [ -z "$READONLY" -a -w "$INFILE" ] && OUTFILE="$INFILE"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   147
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   148
  */*)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   149
    OUTFILE="$OUTPUT"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   150
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   151
  *)
3118
24dae6222579 fixed ISABELLE_OUTPUT, ISABELLE_PATH (finally?);
wenzelm
parents: 3054
diff changeset
   152
    mkdir -p "$ISABELLE_OUTPUT"
24dae6222579 fixed ISABELLE_OUTPUT, ISABELLE_PATH (finally?);
wenzelm
parents: 3054
diff changeset
   153
    OUTFILE="$ISABELLE_OUTPUT/$OUTPUT"
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   154
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   155
esac
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   156
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   157
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   158
## run it!
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   159
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   160
ML_SYSTEM_BASE=$(echo $ML_SYSTEM | cut -f1 -d-)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   161
2704
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
   162
[ -n "$MODES" ] && MLTEXT="print_mode := [$MODES]; $MLTEXT"
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
   163
3502
ec22ba0a26ec added -w option;
wenzelm
parents: 3203
diff changeset
   164
export INFILE OUTFILE MLTEXT TERMINATE NOWRITE
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   165
[ -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
   166
exec $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM_BASE