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