1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Admin/MacOS/App1/script Fri Jul 03 16:10:49 2009 +0200
1.3 @@ -0,0 +1,78 @@
1.4 +#!/bin/bash
1.5 +#
1.6 +# Author: Makarius
1.7 +#
1.8 +# Isabelle application wrapper
1.9 +
1.10 +THIS="$(cd "$(dirname "$0")"; pwd)"
1.11 +THIS_APP="$(cd "$THIS/../.."; pwd)"
1.12 +SUPER_APP="$(cd "$THIS/../../.."; pwd)"
1.13 +
1.14 +
1.15 +# sane environment defaults
1.16 +cd "$HOME"
1.17 +PATH="$PATH:/opt/local/bin"
1.18 +
1.19 +
1.20 +# settings support
1.21 +
1.22 +function choosefrom ()
1.23 +{
1.24 + local RESULT=""
1.25 + local FILE=""
1.26 +
1.27 + for FILE in "$@"
1.28 + do
1.29 + [ -z "$RESULT" -a -e "$FILE" ] && RESULT="$FILE"
1.30 + done
1.31 +
1.32 + [ -z "$RESULT" ] && RESULT="$FILE"
1.33 + echo "$RESULT"
1.34 +}
1.35 +
1.36 +
1.37 +# Isabelle
1.38 +
1.39 +ISABELLE_TOOL="$(choosefrom \
1.40 + "$THIS/Isabelle/bin/isabelle" \
1.41 + "$SUPER_APP/Isabelle/bin/isabelle" \
1.42 + "$HOME/bin/isabelle" \
1.43 + isabelle)"
1.44 +
1.45 +
1.46 +# Proof General / Emacs
1.47 +
1.48 +PROOFGENERAL_EMACS="$(choosefrom \
1.49 + "$THIS/Emacs.app/Contents/MacOS/Emacs" \
1.50 + "$SUPER_APP/Emacs.app/Contents/MacOS/Emacs" \
1.51 + /Applications/Emacs.app/Contents/MacOS/Emacs \
1.52 + "")"
1.53 +
1.54 +if [ -n "$PROOFGENERAL_EMACS" ]; then
1.55 + EMACS_OPTIONS="-p $PROOFGENERAL_EMACS"
1.56 +fi
1.57 +
1.58 +
1.59 +# run interface with error feedback
1.60 +
1.61 +OUTPUT="/tmp/isabelle$$.out"
1.62 +
1.63 +( "$ISABELLE_TOOL" emacs $EMACS_OPTIONS "$@" ) > "$OUTPUT" 2>&1
1.64 +RC=$?
1.65 +
1.66 +if [ "$RC" != 0 ]; then
1.67 + echo >> "$OUTPUT"
1.68 + echo "Return code: $RC" >> "$OUTPUT"
1.69 +fi
1.70 +
1.71 +if [ $(stat -f "%z" "$OUTPUT") != 0 ]; then
1.72 + "$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" textbox \
1.73 + --title "Isabelle" \
1.74 + --informative-text "Isabelle output" \
1.75 + --text-from-file "$OUTPUT" \
1.76 + --button1 "OK"
1.77 +fi
1.78 +
1.79 +rm -f "$OUTPUT"
1.80 +
1.81 +exit "$RC"