Admin/MacOS/script
author wenzelm
Tue, 14 Apr 2009 18:18:15 +0200
changeset 30893 b310beb36645
parent 30891 28c7f7ba9f13
permissions -rwxr-xr-x
more robust handling of emacs options -- this is not necessarily an Isabelle process environment yet;
     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 if [ -n "$PROOFGENERAL_EMACS" ]; then
    52   EMACS_OPTIONS="-p $PROOFGENERAL_EMACS"
    53 fi
    54 
    55 
    56 # run interface with error feedback
    57 
    58 OUTPUT="/tmp/isabelle$$.out"
    59 
    60 ( "$ISABELLE_TOOL" emacs $EMACS_OPTIONS "$@" ) > "$OUTPUT" 2>&1
    61 RC=$?
    62 
    63 if [ "$RC" != 0 ]; then
    64   echo >> "$OUTPUT"
    65   echo "Return code: $RC" >> "$OUTPUT"
    66 fi
    67 
    68 if [ $(stat -f "%z" "$OUTPUT") != 0 ]; then
    69   "$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" textbox \
    70     --title "Isabelle" \
    71     --informative-text "Isabelle output" \
    72     --text-from-file "$OUTPUT" \
    73     --button1 "OK"
    74 fi
    75 
    76 rm -f "$OUTPUT"
    77 
    78 exit "$RC"