Admin/MacOS/App1/script
author wenzelm
Sat, 28 Nov 2009 15:54:25 +0100
changeset 33912 a5e6e849a0d8
parent 31924 47b59620f37f
child 41610 9f99196ebd9f
permissions -rwxr-xr-x
allow spaces within PROOFGENERAL_EMACS;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     1
#!/bin/bash
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     2
#
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     3
# Author: Makarius
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     4
#
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     5
# Isabelle application wrapper
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     6
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
     7
THIS="$(cd "$(dirname "$0")"; pwd)"
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
     8
THIS_APP="$(cd "$THIS/../.."; pwd)"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
     9
SUPER_APP="$(cd "$THIS/../../.."; pwd)"
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    10
29173
c14c9a41f1ac PATH: /opt/local/bin is back again (required for latex etc.);
wenzelm
parents: 29149
diff changeset
    11
c14c9a41f1ac PATH: /opt/local/bin is back again (required for latex etc.);
wenzelm
parents: 29149
diff changeset
    12
# sane environment defaults
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    13
cd "$HOME"
29173
c14c9a41f1ac PATH: /opt/local/bin is back again (required for latex etc.);
wenzelm
parents: 29149
diff changeset
    14
PATH="$PATH:/opt/local/bin"
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    15
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    16
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    17
# settings support
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    18
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    19
function choosefrom ()
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    20
{
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    21
  local RESULT=""
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    22
  local FILE=""
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    23
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    24
  for FILE in "$@"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    25
  do
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    26
    [ -z "$RESULT" -a -e "$FILE" ] && RESULT="$FILE"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    27
  done
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    28
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    29
  [ -z "$RESULT" ] && RESULT="$FILE"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    30
  echo "$RESULT"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    31
}
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    32
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    33
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    34
# Isabelle
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    35
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    36
ISABELLE_TOOL="$(choosefrom \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    37
  "$THIS/Isabelle/bin/isabelle" \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    38
  "$SUPER_APP/Isabelle/bin/isabelle" \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    39
  "$HOME/bin/isabelle" \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    40
  isabelle)"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    41
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    42
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    43
# Proof General / Emacs
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    44
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    45
PROOFGENERAL_EMACS="$(choosefrom \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    46
  "$THIS/Emacs.app/Contents/MacOS/Emacs" \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    47
  "$SUPER_APP/Emacs.app/Contents/MacOS/Emacs" \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    48
  /Applications/Emacs.app/Contents/MacOS/Emacs \
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    49
  "")"
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    50
33912
a5e6e849a0d8 allow spaces within PROOFGENERAL_EMACS;
wenzelm
parents: 31924
diff changeset
    51
declare -a EMACS_OPTIONS=()
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    52
if [ -n "$PROOFGENERAL_EMACS" ]; then
33912
a5e6e849a0d8 allow spaces within PROOFGENERAL_EMACS;
wenzelm
parents: 31924
diff changeset
    53
  EMACS_OPTIONS=(-p "$PROOFGENERAL_EMACS")
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    54
fi
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    55
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    56
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    57
# run interface with error feedback
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    58
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    59
OUTPUT="/tmp/isabelle$$.out"
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    60
33912
a5e6e849a0d8 allow spaces within PROOFGENERAL_EMACS;
wenzelm
parents: 31924
diff changeset
    61
( "$ISABELLE_TOOL" emacs "${EMACS_OPTIONS[@]}" "$@" ) > "$OUTPUT" 2>&1
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    62
RC=$?
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    63
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    64
if [ "$RC" != 0 ]; then
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    65
  echo >> "$OUTPUT"
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    66
  echo "Return code: $RC" >> "$OUTPUT"
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    67
fi
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    68
29149
eae45c2a6811 more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents: 29136
diff changeset
    69
if [ $(stat -f "%z" "$OUTPUT") != 0 ]; then
29136
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    70
  "$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" textbox \
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    71
    --title "Isabelle" \
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    72
    --informative-text "Isabelle output" \
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    73
    --text-from-file "$OUTPUT" \
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    74
    --button1 "OK"
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    75
fi
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    76
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    77
rm -f "$OUTPUT"
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    78
de5b29c25af9 basic setup for MacOS application bundle;
wenzelm
parents:
diff changeset
    79
exit "$RC"