10555
|
1 |
#!/usr/bin/env bash
|
2296
|
2 |
#
|
9788
|
3 |
# Author: Markus Wenzel, TU Muenchen
|
2307
|
4 |
#
|
2734
|
5 |
# DESCRIPTION: get values from Isabelle settings environment
|
2307
|
6 |
|
2296
|
7 |
|
2733
|
8 |
## diagnostics
|
|
9 |
|
10511
|
10 |
PRG="$(basename "$0")"
|
2296
|
11 |
|
|
12 |
function usage()
|
|
13 |
{
|
|
14 |
echo
|
28650
|
15 |
echo "Usage: isabelle $PRG [OPTIONS] [VARNAMES ...]"
|
2296
|
16 |
echo
|
2733
|
17 |
echo " Options are:"
|
|
18 |
echo " -a display complete environment"
|
|
19 |
echo " -b print values only (doesn't work for -a)"
|
73581
|
20 |
echo " -d FILE dump complete environment to file (NUL terminated entries)"
|
2733
|
21 |
echo
|
|
22 |
echo " Get value of VARNAMES from the Isabelle settings."
|
2296
|
23 |
echo
|
|
24 |
exit 1
|
|
25 |
}
|
|
26 |
|
|
27 |
|
2733
|
28 |
## process command line
|
|
29 |
|
|
30 |
# options
|
|
31 |
|
|
32 |
ALL=""
|
|
33 |
BASE=""
|
31497
|
34 |
DUMP=""
|
2733
|
35 |
|
31497
|
36 |
while getopts "abd:" OPT
|
2733
|
37 |
do
|
|
38 |
case "$OPT" in
|
|
39 |
a)
|
|
40 |
ALL=true
|
|
41 |
;;
|
|
42 |
b)
|
|
43 |
BASE=true
|
|
44 |
;;
|
31497
|
45 |
d)
|
|
46 |
DUMP="$OPTARG"
|
|
47 |
;;
|
2733
|
48 |
\?)
|
|
49 |
usage
|
|
50 |
;;
|
|
51 |
esac
|
|
52 |
done
|
|
53 |
|
|
54 |
shift $(($OPTIND - 1))
|
|
55 |
|
|
56 |
|
|
57 |
# args
|
|
58 |
|
62828
|
59 |
[ -z "$ALL" -a -z "$DUMP" -a "$#" -eq 0 ] && usage
|
9788
|
60 |
[ -n "$ALL" -a "$#" -ne 0 ] && usage
|
2733
|
61 |
|
|
62 |
|
2296
|
63 |
## main
|
|
64 |
|
2733
|
65 |
if [ -n "$ALL" ]; then
|
17226
|
66 |
env
|
2733
|
67 |
else
|
9788
|
68 |
for VAR in "$@"
|
2733
|
69 |
do
|
|
70 |
if [ -n "$BASE" ]; then
|
|
71 |
eval "echo \$$VAR"
|
|
72 |
else
|
|
73 |
eval "echo $VAR=\$$VAR"
|
|
74 |
fi
|
|
75 |
done
|
|
76 |
fi
|
31497
|
77 |
|
|
78 |
if [ -n "$DUMP" ]; then
|
61294
|
79 |
export PATH_JVM="$(platform_path "$PATH")"
|
74644
|
80 |
if [ -e "$ISABELLE_PRINTENV" ]; then
|
|
81 |
"$ISABELLE_PRINTENV" -0 > "$DUMP"
|
|
82 |
else
|
|
83 |
exit 2
|
|
84 |
fi
|
31497
|
85 |
fi
|