lib/scripts/getsettings
author wenzelm
Mon, 04 Jan 2010 22:16:48 +0100
changeset 34255 2dd2547acb41
parent 34254 14f6df4f473d
child 34257 b5176fd9ab3c
permissions -rw-r--r--
discontinued old ISABELLE and ISATOOL environment settings;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25434
746677c843a7 ISABELLE_IDENTIFIER is filled in automatically, not taken from the *long* form of isatool version!
wenzelm
parents: 21490
diff changeset
     1
# -*- shell-script -*- :mode=shellscript:
29145
b1c6f4563df7 removed Ids;
wenzelm
parents: 28504
diff changeset
     2
#
9789
wenzelm
parents: 9680
diff changeset
     3
# Author: Markus Wenzel, TU Muenchen
2299
ed9720047d53 getsettings: bash source script to augment current env.
wenzelm
parents:
diff changeset
     4
#
2348
b51e104ecf40 *** empty log message ***
wenzelm
parents: 2307
diff changeset
     5
# getsettings - bash source script to augment current env.
2299
ed9720047d53 getsettings: bash source script to augment current env.
wenzelm
parents:
diff changeset
     6
7770
0497323c1f0b ISABELLE_SETTINGS_PRESENT: avoid multiple invocation;
wenzelm
parents: 6413
diff changeset
     7
if [ -z "$ISABELLE_SETTINGS_PRESENT" ]
0497323c1f0b ISABELLE_SETTINGS_PRESENT: avoid multiple invocation;
wenzelm
parents: 6413
diff changeset
     8
then
0497323c1f0b ISABELLE_SETTINGS_PRESENT: avoid multiple invocation;
wenzelm
parents: 6413
diff changeset
     9
3185
wenzelm
parents: 3118
diff changeset
    10
set -o allexport
wenzelm
parents: 3118
diff changeset
    11
7770
0497323c1f0b ISABELLE_SETTINGS_PRESENT: avoid multiple invocation;
wenzelm
parents: 6413
diff changeset
    12
ISABELLE_SETTINGS_PRESENT=true
0497323c1f0b ISABELLE_SETTINGS_PRESENT: avoid multiple invocation;
wenzelm
parents: 6413
diff changeset
    13
15972
8ac3803c8f73 export ISABELLE_HOME, do not normalize;
wenzelm
parents: 15849
diff changeset
    14
export ISABELLE_HOME
12598
fa556d3fe5f2 warn for spaces in ISABELLE_HOME;
wenzelm
parents: 11553
diff changeset
    15
if { echo -n "$ISABELLE_HOME" | fgrep " " >/dev/null; }
fa556d3fe5f2 warn for spaces in ISABELLE_HOME;
wenzelm
parents: 11553
diff changeset
    16
then
fa556d3fe5f2 warn for spaces in ISABELLE_HOME;
wenzelm
parents: 11553
diff changeset
    17
  echo 1>&2 "### White space in ISABELLE_HOME may cause strange problems later on!"
fa556d3fe5f2 warn for spaces in ISABELLE_HOME;
wenzelm
parents: 11553
diff changeset
    18
  echo 1>&2 "### ISABELLE_HOME=\"$ISABELLE_HOME\""
fa556d3fe5f2 warn for spaces in ISABELLE_HOME;
wenzelm
parents: 11553
diff changeset
    19
fi
2736
476adc742599 added ISABELLE_HOME normalization;
wenzelm
parents: 2643
diff changeset
    20
11553
wenzelm
parents: 9789
diff changeset
    21
#key executables
28499
eff93bc3c14f ISABELLE_PROCESS replaces ISABELLE and ISABELLE_TOOL replaces ISATOOL -- old bindings stay for a while (legacy feature);
wenzelm
parents: 28055
diff changeset
    22
ISABELLE_PROCESS="$ISABELLE_HOME/bin/isabelle-process"
28504
7ad7d7d6df47 simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents: 28499
diff changeset
    23
ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"
2299
ed9720047d53 getsettings: bash source script to augment current env.
wenzelm
parents:
diff changeset
    24
34254
14f6df4f473d shell functions "isabelle-process" and "isabelle" refer to the proper executables statically -- for interactive use or sloppy bash scripts;
wenzelm
parents: 34043
diff changeset
    25
function isabelle-process ()
14f6df4f473d shell functions "isabelle-process" and "isabelle" refer to the proper executables statically -- for interactive use or sloppy bash scripts;
wenzelm
parents: 34043
diff changeset
    26
{
14f6df4f473d shell functions "isabelle-process" and "isabelle" refer to the proper executables statically -- for interactive use or sloppy bash scripts;
wenzelm
parents: 34043
diff changeset
    27
  "$ISABELLE_PROCESS" "$@"
14f6df4f473d shell functions "isabelle-process" and "isabelle" refer to the proper executables statically -- for interactive use or sloppy bash scripts;
wenzelm
parents: 34043
diff changeset
    28
}
14f6df4f473d shell functions "isabelle-process" and "isabelle" refer to the proper executables statically -- for interactive use or sloppy bash scripts;
wenzelm
parents: 34043
diff changeset
    29
14f6df4f473d shell functions "isabelle-process" and "isabelle" refer to the proper executables statically -- for interactive use or sloppy bash scripts;
wenzelm
parents: 34043
diff changeset
    30
function isabelle ()
14f6df4f473d shell functions "isabelle-process" and "isabelle" refer to the proper executables statically -- for interactive use or sloppy bash scripts;
wenzelm
parents: 34043
diff changeset
    31
{
14f6df4f473d shell functions "isabelle-process" and "isabelle" refer to the proper executables statically -- for interactive use or sloppy bash scripts;
wenzelm
parents: 34043
diff changeset
    32
  "$ISABELLE_TOOL" "$@"
14f6df4f473d shell functions "isabelle-process" and "isabelle" refer to the proper executables statically -- for interactive use or sloppy bash scripts;
wenzelm
parents: 34043
diff changeset
    33
}
14f6df4f473d shell functions "isabelle-process" and "isabelle" refer to the proper executables statically -- for interactive use or sloppy bash scripts;
wenzelm
parents: 34043
diff changeset
    34
25434
746677c843a7 ISABELLE_IDENTIFIER is filled in automatically, not taken from the *long* form of isatool version!
wenzelm
parents: 21490
diff changeset
    35
#Isabelle distribution identifier -- filled in automatically!
746677c843a7 ISABELLE_IDENTIFIER is filled in automatically, not taken from the *long* form of isatool version!
wenzelm
parents: 21490
diff changeset
    36
ISABELLE_IDENTIFIER=""
21490
2f83b11c301b added ISABELLE_IDENTIFIER;
wenzelm
parents: 21468
diff changeset
    37
2643
a7f469c0ba59 tuned comments;
wenzelm
parents: 2621
diff changeset
    38
#users tend to put strange things in here ...
2621
e9e491033b54 globally unset ENV, BASH_ENV;
wenzelm
parents: 2590
diff changeset
    39
unset ENV
e9e491033b54 globally unset ENV, BASH_ENV;
wenzelm
parents: 2590
diff changeset
    40
unset BASH_ENV
e9e491033b54 globally unset ENV, BASH_ENV;
wenzelm
parents: 2590
diff changeset
    41
9680
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    42
#support easy settings
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    43
function choosefrom ()
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    44
{
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    45
  local RESULT=""
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    46
  local FILE=""
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    47
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    48
  for FILE in "$@"
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    49
  do
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    50
    [ -z "$RESULT" -a -e "$FILE" ] && RESULT="$FILE"
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    51
  done
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    52
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    53
  [ -z "$RESULT" ] && RESULT="$FILE"
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    54
  echo "$RESULT"
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    55
}
6581bfc8421e choosefrom: support easy settings;
wenzelm
parents: 9227
diff changeset
    56
27914
9a7f17370ffb refined scala/java wrappers via isatool;
wenzelm
parents: 27911
diff changeset
    57
#JVM path wrapper
25650
ce061f5083d7 added javapath (for cygwin);
wenzelm
parents: 25434
diff changeset
    58
if [ "$OSTYPE" = cygwin ]; then
27908
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    59
  CLASSPATH="$(cygpath -u -p "$CLASSPATH")"
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    60
  function jvmpath() { cygpath -w -p "$@"; }
34043
7129fab1fe4f more robust Cygwin.config: actually check Wow6432Node, prefer explicit CYGWIN_ROOT in any case;
wenzelm
parents: 33512
diff changeset
    61
  CYGWIN_ROOT="$(jvmpath "/")"
25650
ce061f5083d7 added javapath (for cygwin);
wenzelm
parents: 25434
diff changeset
    62
else
27908
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    63
  function jvmpath() { echo "$@"; }
25650
ce061f5083d7 added javapath (for cygwin);
wenzelm
parents: 25434
diff changeset
    64
fi
28055
eb855c3db657 provide HOME_JVM=HOME to prevent implicit cygpath mangling;
wenzelm
parents: 27940
diff changeset
    65
HOME_JVM="$HOME"
25650
ce061f5083d7 added javapath (for cygwin);
wenzelm
parents: 25434
diff changeset
    66
27908
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    67
#CLASSPATH convenience
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    68
function classpath () {
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    69
  for X in "$@"
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    70
  do
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    71
    if [ -z "$CLASSPATH" ]; then
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    72
      CLASSPATH="$X"
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    73
    else
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    74
      CLASSPATH="$CLASSPATH:$X"
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    75
    fi
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    76
  done
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    77
}
97f8b7c0f420 refined JVM path wrappers: Isabelle environment holds Unix version of CLASSPATH, javawrapper/scalawrapper convert it back;
wenzelm
parents: 25650
diff changeset
    78
32390
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32321
diff changeset
    79
#arrays
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32321
diff changeset
    80
function splitarray ()
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32321
diff changeset
    81
{
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32321
diff changeset
    82
  SPLITARRAY=()
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32321
diff changeset
    83
  local IFS="$1"; shift
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32321
diff changeset
    84
  for X in $*
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32321
diff changeset
    85
  do
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32321
diff changeset
    86
    SPLITARRAY["${#SPLITARRAY[@]}"]="$X"
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32321
diff changeset
    87
  done
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32321
diff changeset
    88
}
468eff174a77 function splitarray: splightly more abstract version that accomodates older bashes;
wenzelm
parents: 32321
diff changeset
    89
32305
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
    90
#nested components
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
    91
ISABELLE_COMPONENTS=""
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
    92
function init_component ()
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
    93
{
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
    94
  local COMPONENT="$1"
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
    95
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
    96
  if [ ! -d "$COMPONENT" ]; then
33295
ce8faf41b0d4 proper nested quotes;
wenzelm
parents: 33294
diff changeset
    97
    echo >&2 "Bad Isabelle component: \"$COMPONENT\""
32305
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
    98
    exit 2
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
    99
  elif [ -z "$ISABELLE_COMPONENTS" ]; then
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   100
    ISABELLE_COMPONENTS="$COMPONENT"
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   101
  else
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   102
    ISABELLE_COMPONENTS="$ISABELLE_COMPONENTS:$COMPONENT"
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   103
  fi
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   104
  if [ -f "$COMPONENT/etc/settings" ]; then
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   105
    source "$COMPONENT/etc/settings" || exit 2
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   106
  fi
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   107
  if [ -f "$COMPONENT/etc/components" ]; then
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   108
    {
33512
771ec7306438 init_component: slightly more robust read (raw input, succeed on non-terminated last line);
wenzelm
parents: 33295
diff changeset
   109
      while { unset REPLY; read -r; test "$?" = 0 -o -n "$REPLY"; }
771ec7306438 init_component: slightly more robust read (raw input, succeed on non-terminated last line);
wenzelm
parents: 33295
diff changeset
   110
      do
32305
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   111
        case "$REPLY" in
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   112
          \#* | "") ;;
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   113
          /*) init_component "$REPLY" ;;
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   114
          *) init_component "$COMPONENT/$REPLY" ;;
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   115
        esac
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   116
      done
33295
ce8faf41b0d4 proper nested quotes;
wenzelm
parents: 33294
diff changeset
   117
    } < "$COMPONENT/etc/components"
32305
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   118
  fi
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   119
}
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   120
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   121
#main components
c5523ded51d9 basic support for components (which imitate the usual Isabelle directory layout);
wenzelm
parents: 31520
diff changeset
   122
init_component "$ISABELLE_HOME"
9789
wenzelm
parents: 9680
diff changeset
   123
wenzelm
parents: 9680
diff changeset
   124
[ "$ISABELLE_HOME" -ef "$ISABELLE_HOME_USER" ] && \
32321
13920dbe4547 more uniform handling of ISABELLE_HOME_USER component;
wenzelm
parents: 32305
diff changeset
   125
  { echo >&2 "### ISABELLE_HOME and ISABELLE_HOME_USER must not be the same directory!"; }
13920dbe4547 more uniform handling of ISABELLE_HOME_USER component;
wenzelm
parents: 32305
diff changeset
   126
[ -d "$ISABELLE_HOME_USER" ] && init_component "$ISABELLE_HOME_USER"
2299
ed9720047d53 getsettings: bash source script to augment current env.
wenzelm
parents:
diff changeset
   127
21490
2f83b11c301b added ISABELLE_IDENTIFIER;
wenzelm
parents: 21468
diff changeset
   128
#ML system identifier
6413
b2f2770ef8d9 ML_PLATFORM;
wenzelm
parents: 3185
diff changeset
   129
if [ -z "$ML_PLATFORM" ]; then
b2f2770ef8d9 ML_PLATFORM;
wenzelm
parents: 3185
diff changeset
   130
  ML_IDENTIFIER="$ML_SYSTEM"
b2f2770ef8d9 ML_PLATFORM;
wenzelm
parents: 3185
diff changeset
   131
else
b2f2770ef8d9 ML_PLATFORM;
wenzelm
parents: 3185
diff changeset
   132
  ML_IDENTIFIER="${ML_SYSTEM}_${ML_PLATFORM}"
b2f2770ef8d9 ML_PLATFORM;
wenzelm
parents: 3185
diff changeset
   133
fi
21468
c7892915ed10 add ISABELLE_VERSION to ML_IDENTIFIER, unless this is repository or build;
wenzelm
parents: 16293
diff changeset
   134
6413
b2f2770ef8d9 ML_PLATFORM;
wenzelm
parents: 3185
diff changeset
   135
ISABELLE_OUTPUT="$ISABELLE_OUTPUT/$ML_IDENTIFIER"
3118
24dae6222579 fixed ISABELLE_OUTPUT, ISABELLE_PATH (finally?);
wenzelm
parents: 2968
diff changeset
   136
2299
ed9720047d53 getsettings: bash source script to augment current env.
wenzelm
parents:
diff changeset
   137
set +o allexport
7770
0497323c1f0b ISABELLE_SETTINGS_PRESENT: avoid multiple invocation;
wenzelm
parents: 6413
diff changeset
   138
0497323c1f0b ISABELLE_SETTINGS_PRESENT: avoid multiple invocation;
wenzelm
parents: 6413
diff changeset
   139
fi