bin/isabelle
author wenzelm
Thu, 15 May 1997 15:18:00 +0200
changeset 3203 af42c8cc8e75
parent 3184 4e0bbfb113d5
child 3502 ec22ba0a26ec
permissions -rwxr-xr-x
fixed bash path!!!
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"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    29
  echo
3184
4e0bbfb113d5 renamed DEFAULT_LOGIC to ISABELLE_LOGIC;
wenzelm
parents: 3183
diff changeset
    30
  echo "  INPUT (default \"$ISABELLE_LOGIC\") and OUTPUT specify in/out heaps."
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    31
  echo "  These are either names to be searched in the Isabelle path, or actual"
2343
2588b63b42ca added -norc option;
wenzelm
parents: 2308
diff changeset
    32
  echo "  file names (then containing at least one /)."
2768
bc6d915b8019 renamed SYSTEM to RAW_ML_SYSTEM;
wenzelm
parents: 2735
diff changeset
    33
  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
    34
  echo
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    35
  exit 1
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    36
}
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    37
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    38
function fail()
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    39
{
2343
2588b63b42ca added -norc option;
wenzelm
parents: 2308
diff changeset
    40
  echo "$1" >&2
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    41
  exit 2
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    42
}
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
## process command line
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    46
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    47
# options
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    48
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    49
MLTEXT=""
2704
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    50
MODES=""
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    51
TERMINATE=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    52
READONLY=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    53
3183
537f7281d42c removed -u option;
wenzelm
parents: 3118
diff changeset
    54
while getopts "e:m:qr" OPT
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    55
do
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    56
  case "$OPT" in
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    57
    e)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    58
      MLTEXT="$MLTEXT $OPTARG"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    59
      ;;
2704
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    60
    m)
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    61
      if [ -z "$MODES" ]; then
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    62
        MODES="\"$OPTARG\""
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    63
      else
2711
098f9ce0541a fixed -m order;
wenzelm
parents: 2704
diff changeset
    64
        MODES="\"$OPTARG\", $MODES"
2704
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    65
      fi
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
    66
      ;;
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    67
    q)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    68
      TERMINATE=true
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    69
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    70
    r)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    71
      READONLY=true
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    72
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    73
    \?)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    74
      usage
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    75
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    76
  esac
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    77
done
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    78
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    79
shift $(($OPTIND - 1))
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    80
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    81
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    82
# args
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    83
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    84
INPUT=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    85
OUTPUT=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    86
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    87
if [ $# -ge 1 ]; then
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    88
  INPUT="$1"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    89
  shift
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    90
fi
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
  OUTPUT="$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
2936
bd33e7aae062 fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents: 2768
diff changeset
    97
[ $# -ne 0 ] && { echo "Bad args: $*"; usage; }
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    98
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    99
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   100
## check ML system
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   101
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   102
[ -z "$ML_SYSTEM" ] && fail "Missing ML system settings! Unable to run Isabelle."
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
## input heap file
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   106
3184
4e0bbfb113d5 renamed DEFAULT_LOGIC to ISABELLE_LOGIC;
wenzelm
parents: 3183
diff changeset
   107
[ -z "$INPUT" ] && INPUT="$ISABELLE_LOGIC"
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   108
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   109
case "$INPUT" in
2768
bc6d915b8019 renamed SYSTEM to RAW_ML_SYSTEM;
wenzelm
parents: 2735
diff changeset
   110
  RAW_ML_SYSTEM)
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   111
    INFILE=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   112
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   113
  */*)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   114
    INFILE="$INPUT"
2343
2588b63b42ca added -norc option;
wenzelm
parents: 2308
diff changeset
   115
    [ ! -f "$INFILE" ] && fail "Bad heap file: \"$INFILE\""
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   116
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   117
  *)
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   118
    ISA_PATH=""
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   119
    INFILE=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   120
    for DIR in $(echo $ISABELLE_PATH | tr : " ")
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   121
    do
2968
8ba30b031f31 eliminated PLATFORM;
wenzelm
parents: 2936
diff changeset
   122
      ISA_PATH="$ISA_PATH $DIR"
8ba30b031f31 eliminated PLATFORM;
wenzelm
parents: 2936
diff changeset
   123
      [ -z "$INFILE" -a -f $DIR/$INPUT ] && INFILE=$DIR/$INPUT
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   124
    done
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   125
    if [ -z "$INFILE" ]; then
2343
2588b63b42ca added -norc option;
wenzelm
parents: 2308
diff changeset
   126
      echo "Unknown logic \"$INPUT\" -- no heap file found in:" >&2
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   127
      for DIR in $ISA_PATH
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   128
      do
2343
2588b63b42ca added -norc option;
wenzelm
parents: 2308
diff changeset
   129
        echo "  $DIR" >&2
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   130
      done
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   131
      exit 2
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   132
    fi
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   133
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   134
esac
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   135
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   136
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   137
## output heap file
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   138
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   139
case "$OUTPUT" in
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   140
  "")
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   141
    [ -z "$READONLY" -a -w "$INFILE" ] && OUTFILE="$INFILE"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   142
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   143
  */*)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   144
    OUTFILE="$OUTPUT"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   145
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   146
  *)
3118
24dae6222579 fixed ISABELLE_OUTPUT, ISABELLE_PATH (finally?);
wenzelm
parents: 3054
diff changeset
   147
    mkdir -p "$ISABELLE_OUTPUT"
24dae6222579 fixed ISABELLE_OUTPUT, ISABELLE_PATH (finally?);
wenzelm
parents: 3054
diff changeset
   148
    OUTFILE="$ISABELLE_OUTPUT/$OUTPUT"
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   149
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   150
esac
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   151
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   152
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   153
## run it!
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   154
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   155
ML_SYSTEM_BASE=$(echo $ML_SYSTEM | cut -f1 -d-)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   156
2704
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
   157
[ -n "$MODES" ] && MLTEXT="print_mode := [$MODES]; $MLTEXT"
afa01c9f1ab0 more robust handling of invocation errors;
wenzelm
parents: 2591
diff changeset
   158
3054
c16029f41ad9 removed -c option;
wenzelm
parents: 3007
diff changeset
   159
export INFILE OUTFILE 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