author | paulson |
Mon, 06 Aug 2012 15:01:15 +0100 | |
changeset 48695 | b5d7a35bdd6a |
parent 48631 | 81c81f13d152 |
child 50792 | b7e38c13d87b |
permissions | -rw-r--r-- |
29136 | 1 |
#!/bin/bash |
2 |
# |
|
3 |
# Author: Makarius |
|
4 |
# |
|
5 |
# Isabelle application wrapper |
|
6 |
||
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 | 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 |
41643
10b0d338d99e
default UTF-8 locale, to work with funny base directory (e.g. Chinese);
wenzelm
parents:
41642
diff
changeset
|
13 |
|
29136 | 14 |
cd "$HOME" |
44985
272e8e4e4fc7
imitate Apple in setting initial shell PATH -- especially relevant for MacTeX, MacPorts etc.;
wenzelm
parents:
44948
diff
changeset
|
15 |
if [ -x /usr/libexec/path_helper ]; then |
272e8e4e4fc7
imitate Apple in setting initial shell PATH -- especially relevant for MacTeX, MacPorts etc.;
wenzelm
parents:
44948
diff
changeset
|
16 |
eval $(/usr/libexec/path_helper -s) |
272e8e4e4fc7
imitate Apple in setting initial shell PATH -- especially relevant for MacTeX, MacPorts etc.;
wenzelm
parents:
44948
diff
changeset
|
17 |
fi |
29136 | 18 |
|
41643
10b0d338d99e
default UTF-8 locale, to work with funny base directory (e.g. Chinese);
wenzelm
parents:
41642
diff
changeset
|
19 |
[ -z "$LANG" ] && export LANG=en_US.UTF-8 |
10b0d338d99e
default UTF-8 locale, to work with funny base directory (e.g. Chinese);
wenzelm
parents:
41642
diff
changeset
|
20 |
|
29136 | 21 |
|
29149
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
22 |
# settings support |
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 |
function choosefrom () |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
25 |
{ |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
26 |
local RESULT="" |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
27 |
local FILE="" |
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 |
for FILE in "$@" |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
30 |
do |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
31 |
[ -z "$RESULT" -a -e "$FILE" ] && RESULT="$FILE" |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
32 |
done |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
33 |
|
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
34 |
[ -z "$RESULT" ] && RESULT="$FILE" |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
35 |
echo "$RESULT" |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
36 |
} |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
37 |
|
29136 | 38 |
|
29149
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
39 |
# Isabelle |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
40 |
|
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
41 |
ISABELLE_TOOL="$(choosefrom \ |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
42 |
"$THIS/Isabelle/bin/isabelle" \ |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
43 |
"$SUPER_APP/Isabelle/bin/isabelle" \ |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
44 |
"$HOME/bin/isabelle" \ |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
45 |
isabelle)" |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
46 |
|
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
47 |
|
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
48 |
# Proof General / 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 |
PROOFGENERAL_EMACS="$(choosefrom \ |
48695 | 51 |
"$THIS/Aquamacs.app/Contents/MacOS/Aquamacs" \ |
52 |
"$SUPER_APP/Aquamacs.app/Contents/MacOS/Aquamacs" \ |
|
53 |
/Applications/Aquamacs.app/Contents/MacOS/Aquamacs \ |
|
29149
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
54 |
"")" |
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
55 |
|
33912 | 56 |
declare -a EMACS_OPTIONS=() |
29149
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
57 |
if [ -n "$PROOFGENERAL_EMACS" ]; then |
33912 | 58 |
EMACS_OPTIONS=(-p "$PROOFGENERAL_EMACS") |
29136 | 59 |
fi |
60 |
||
61 |
||
29149
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
62 |
# run interface with error feedback |
29136 | 63 |
|
44881 | 64 |
ISABELLE_INTERFACE_CHOICE="$("$ISABELLE_TOOL" getenv -b ISABELLE_INTERFACE_CHOICE)" |
65 |
if [ "$ISABELLE_INTERFACE_CHOICE" != emacs -a "$ISABELLE_INTERFACE_CHOICE" != jedit ] |
|
66 |
then |
|
67 |
declare -a CHOICE |
|
68 |
CHOICE=($("$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" dropdown \ |
|
69 |
--title Isabelle \ |
|
70 |
--text "Which Isabelle interface?" \ |
|
71 |
--items "Emacs / Proof General" "Isabelle/jEdit PIDE" \ |
|
72 |
--button2 "OK, do not ask again" --button1 "OK")) |
|
73 |
if [ "${CHOICE[1]}" = 0 ]; then |
|
74 |
ISABELLE_INTERFACE_CHOICE=emacs |
|
75 |
else |
|
76 |
ISABELLE_INTERFACE_CHOICE=jedit |
|
77 |
fi |
|
78 |
if [ "${CHOICE[0]}" = 2 ]; then |
|
79 |
ISABELLE_HOME_USER="$("$ISABELLE_TOOL" getenv -b ISABELLE_HOME_USER)" |
|
80 |
mkdir -p "$ISABELLE_HOME_USER/etc" |
|
81 |
( echo; echo "ISABELLE_INTERFACE_CHOICE=$ISABELLE_INTERFACE_CHOICE"; ) \ |
|
82 |
>> "$ISABELLE_HOME_USER/etc/settings" |
|
83 |
"$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" ok-msgbox \ |
|
84 |
--title Isabelle \ |
|
85 |
--text Note \ |
|
86 |
--informative-text "ISABELLE_INTERFACE_CHOICE stored in $ISABELLE_HOME_USER/etc/settings" \ |
|
87 |
--no-cancel |
|
88 |
fi |
|
89 |
fi |
|
90 |
||
29136 | 91 |
OUTPUT="/tmp/isabelle$$.out" |
92 |
||
44881 | 93 |
if [ "$ISABELLE_INTERFACE_CHOICE" = emacs ]; then |
44880 | 94 |
( "$ISABELLE_TOOL" emacs "${EMACS_OPTIONS[@]}" "$@" ) > "$OUTPUT" 2>&1 |
95 |
RC=$? |
|
96 |
else |
|
45095
bf7a8906c0cb
retain output, which is required for non-existent JRE, for example (cf. b455e4f42c04);
wenzelm
parents:
44985
diff
changeset
|
97 |
( "$ISABELLE_TOOL" jedit "$@" ) > "$OUTPUT" 2>&1 |
44880 | 98 |
RC=$? |
99 |
fi |
|
29136 | 100 |
|
101 |
if [ "$RC" != 0 ]; then |
|
102 |
echo >> "$OUTPUT" |
|
103 |
echo "Return code: $RC" >> "$OUTPUT" |
|
104 |
fi |
|
105 |
||
29149
eae45c2a6811
more sophisticated MacOS interface script (mostly for Carbon Emacs);
wenzelm
parents:
29136
diff
changeset
|
106 |
if [ $(stat -f "%z" "$OUTPUT") != 0 ]; then |
29136 | 107 |
"$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" textbox \ |
108 |
--title "Isabelle" \ |
|
109 |
--informative-text "Isabelle output" \ |
|
110 |
--text-from-file "$OUTPUT" \ |
|
111 |
--button1 "OK" |
|
112 |
fi |
|
113 |
||
114 |
rm -f "$OUTPUT" |
|
115 |
||
116 |
exit "$RC" |