61170
|
1 |
#!/usr/bin/env bash
|
|
2 |
#
|
|
3 |
# Author: Makarius
|
|
4 |
#
|
|
5 |
# DESCRIPTION: Isabelle/jEdit client for already running application
|
|
6 |
|
|
7 |
## settings
|
|
8 |
|
|
9 |
SERVER_NAME="${ISABELLE_IDENTIFIER:-Isabelle}"
|
|
10 |
|
|
11 |
case "$ISABELLE_JAVA_PLATFORM" in
|
|
12 |
x86_64-*)
|
|
13 |
JEDIT_JAVA_OPTIONS="$JEDIT_JAVA_OPTIONS64"
|
|
14 |
;;
|
|
15 |
*)
|
|
16 |
JEDIT_JAVA_OPTIONS="$JEDIT_JAVA_OPTIONS32"
|
|
17 |
;;
|
|
18 |
esac
|
|
19 |
|
|
20 |
declare -a JAVA_ARGS; eval "JAVA_ARGS=($JEDIT_JAVA_SYSTEM_OPTIONS $JEDIT_JAVA_OPTIONS)"
|
|
21 |
|
|
22 |
|
|
23 |
## diagnostics
|
|
24 |
|
|
25 |
PRG="$(basename "$0")"
|
|
26 |
|
|
27 |
function usage()
|
|
28 |
{
|
|
29 |
echo
|
|
30 |
echo "Usage: isabelle $PRG [OPTIONS] [FILES ...]"
|
|
31 |
echo
|
|
32 |
echo " Options are:"
|
|
33 |
echo " -c only check presence of server"
|
|
34 |
echo " -n only report server name"
|
|
35 |
echo " -s NAME server name (default $SERVER_NAME)"
|
|
36 |
echo
|
|
37 |
echo " Connect to already running Isabelle/jEdit instance and open FILES"
|
|
38 |
echo
|
|
39 |
exit 1
|
|
40 |
}
|
|
41 |
|
|
42 |
function fail()
|
|
43 |
{
|
|
44 |
echo "$1" >&2
|
|
45 |
exit 2
|
|
46 |
}
|
|
47 |
|
|
48 |
function failed()
|
|
49 |
{
|
|
50 |
fail "Failed!"
|
|
51 |
}
|
|
52 |
|
|
53 |
|
|
54 |
## process command line
|
|
55 |
|
|
56 |
# options
|
|
57 |
|
|
58 |
CHECK_ONLY="false"
|
|
59 |
NAME_ONLY="false"
|
|
60 |
|
|
61 |
while getopts "cns:" OPT
|
|
62 |
do
|
|
63 |
case "$OPT" in
|
|
64 |
c)
|
|
65 |
CHECK_ONLY="true"
|
|
66 |
;;
|
|
67 |
n)
|
|
68 |
NAME_ONLY="true"
|
|
69 |
;;
|
|
70 |
s)
|
|
71 |
SERVER_NAME="$OPTARG"
|
|
72 |
;;
|
|
73 |
\?)
|
|
74 |
usage
|
|
75 |
;;
|
|
76 |
esac
|
|
77 |
done
|
|
78 |
|
|
79 |
shift $(($OPTIND - 1))
|
|
80 |
|
|
81 |
|
|
82 |
# args
|
|
83 |
|
|
84 |
declare -a ARGS=()
|
|
85 |
|
|
86 |
while [ "$#" -gt 0 ]
|
|
87 |
do
|
61294
|
88 |
ARGS["${#ARGS[@]}"]="$(platform_path "$1")"
|
61170
|
89 |
shift
|
|
90 |
done
|
|
91 |
|
|
92 |
|
|
93 |
## main
|
|
94 |
|
|
95 |
if [ "$CHECK_ONLY" = true ]
|
|
96 |
then
|
|
97 |
[ -f "$JEDIT_SETTINGS/$SERVER_NAME" ]
|
|
98 |
exit $?
|
|
99 |
fi
|
|
100 |
|
|
101 |
if [ "$NAME_ONLY" = true ]
|
|
102 |
then
|
|
103 |
echo "$SERVER_NAME"
|
|
104 |
exit
|
|
105 |
fi
|
|
106 |
|
|
107 |
"$ISABELLE_TOOL" jedit -b || exit $?
|
|
108 |
|
|
109 |
if [ -f "$JEDIT_SETTINGS/$SERVER_NAME" ]
|
|
110 |
then
|
|
111 |
exec "$ISABELLE_TOOL" java "${JAVA_ARGS[@]}" -jar "$JEDIT_HOME/dist/jedit.jar" \
|
61294
|
112 |
"-settings=$(platform_path "$JEDIT_SETTINGS")" -server="$SERVER_NAME" -reuseview "${ARGS[@]}"
|
61170
|
113 |
else
|
|
114 |
fail "Isabelle/jEdit server \"$SERVER_NAME\" not active"
|
|
115 |
fi
|