Admin/MacOS/App1/script
author wenzelm
Tue, 18 Jan 2011 21:33:07 +0100
changeset 41858 9f99196ebd9f
parent 33928 a5e6e849a0d8
child 41890 b9442d9ce7f5
permissions -rwxr-xr-x
isabelle jedit as alternative;
     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" jedit "$@" ) > "$OUTPUT" 2>&1
    62 ( "$ISABELLE_TOOL" emacs "${EMACS_OPTIONS[@]}" "$@" ) > "$OUTPUT" 2>&1
    63 RC=$?
    64 
    65 if [ "$RC" != 0 ]; then
    66   echo >> "$OUTPUT"
    67   echo "Return code: $RC" >> "$OUTPUT"
    68 fi
    69 
    70 if [ $(stat -f "%z" "$OUTPUT") != 0 ]; then
    71   "$THIS/CocoaDialog.app/Contents/MacOS/CocoaDialog" textbox \
    72     --title "Isabelle" \
    73     --informative-text "Isabelle output" \
    74     --text-from-file "$OUTPUT" \
    75     --button1 "OK"
    76 fi
    77 
    78 rm -f "$OUTPUT"
    79 
    80 exit "$RC"