1 | #!/bin/bash |
---|
2 | |
---|
3 | nargs=$# |
---|
4 | args="$*" |
---|
5 | |
---|
6 | # error message function |
---|
7 | err () { |
---|
8 | echo "`basename $0`: $@" 1>&2 |
---|
9 | exit 1 |
---|
10 | } |
---|
11 | |
---|
12 | # Add to the path variable named by $1 the component $2. $3 must be |
---|
13 | # "append" or "prepend" to indicate where the component is added. |
---|
14 | |
---|
15 | addpath () { |
---|
16 | eval value=\"\$$1\" |
---|
17 | case "$value" in |
---|
18 | *:$2:*|*:$2|$2:*|$2) |
---|
19 | result="$value" |
---|
20 | ;; |
---|
21 | "") |
---|
22 | result="$2" |
---|
23 | ;; |
---|
24 | *) |
---|
25 | case "$3" in |
---|
26 | p*) |
---|
27 | result="$2:${value}" |
---|
28 | ;; |
---|
29 | *) |
---|
30 | result="${value}:$2" |
---|
31 | ;; |
---|
32 | esac |
---|
33 | esac |
---|
34 | eval $1=$result |
---|
35 | unset result value |
---|
36 | } |
---|
37 | |
---|
38 | # convenience routine which appends a string to a path. |
---|
39 | append () { |
---|
40 | addpath "$1" "$2" append |
---|
41 | } |
---|
42 | |
---|
43 | # convenience routine which prepends a string to a path. |
---|
44 | prepend () { |
---|
45 | addpath "$1" "$2" prepend |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | case "X${ARBHOME}" in |
---|
50 | X) |
---|
51 | if [ -x /usr/arb/bin/arb ];then |
---|
52 | ARB=/usr/arb/bin/arb |
---|
53 | else |
---|
54 | case "$0" in |
---|
55 | /*) |
---|
56 | ARB="$0";; |
---|
57 | *) |
---|
58 | if ARB=`which $0`; then |
---|
59 | echo $ARB |
---|
60 | else |
---|
61 | ARB=`pwd`/$0 |
---|
62 | fi;; |
---|
63 | esac |
---|
64 | fi |
---|
65 | |
---|
66 | ARBBIN=`dirname $ARB` |
---|
67 | export ARBBIN |
---|
68 | ARBHOME=`dirname $ARBBIN` |
---|
69 | export ARBHOME |
---|
70 | echo "Environment Variable ARBHOME was empty" |
---|
71 | esac |
---|
72 | |
---|
73 | echo "Using ARBHOME='$ARBHOME'" |
---|
74 | |
---|
75 | prepend PATH $ARBHOME/bin |
---|
76 | prepend LD_LIBRARY_PATH $ARBHOME/lib |
---|
77 | append LD_LIBRARY_PATH /usr/dt/lib |
---|
78 | append LD_LIBRARY_PATH /usr/openwin/lib |
---|
79 | append LD_LIBRARY_PATH $ARBHOME/lib/addlibs |
---|
80 | prepend SHLIB_PATH $ARBHOME/lib |
---|
81 | append SHLIB_PATH $ARBHOME/lib/addlibs |
---|
82 | |
---|
83 | # environment variables that this shell script sets/changes: |
---|
84 | export LD_LIBRARY_PATH MANPATH PATH ARBHOME SHLIB_PATH |
---|
85 | |
---|
86 | # global envs: |
---|
87 | |
---|
88 | export PWD HOME USER |
---|
89 | |
---|
90 | if [ -x $ARBHOME/bin/ghostview ] ; then |
---|
91 | GS_LIB="$ARBHOME/DEPOT/ghostscript" |
---|
92 | export GS_LIB |
---|
93 | fi |
---|
94 | |
---|
95 | ARB_PID="$$"; export ARB_PID |
---|
96 | |
---|
97 | ARB_PROPERTIES=${HOME}/.arb_prop |
---|
98 | |
---|
99 | if [ ! -d ${ARB_PROPERTIES} ] ; then |
---|
100 | echo "Directory ${ARB_PROPERTIES} not found - creating ..." |
---|
101 | mkdir ${ARB_PROPERTIES} |
---|
102 | fi |
---|
103 | |
---|
104 | if [ "X$ARBMACROHOME" = "X" ] ; then |
---|
105 | ARBMACROHOME="${ARB_PROPERTIES}/macros"; |
---|
106 | export ARBMACROHOME |
---|
107 | fi |
---|
108 | if [ ! -d ${ARBMACROHOME} ] ; then |
---|
109 | echo "Directory $ARBMACROHOME not found - creating ..." |
---|
110 | mkdir ${ARBMACROHOME} |
---|
111 | fi |
---|
112 | |
---|
113 | if [ "X$ARBMACRO" = "X" ] ; then |
---|
114 | ARBMACRO="$ARBHOME/lib/macros" |
---|
115 | export ARBMACRO |
---|
116 | fi |
---|
117 | if [ ! -d ${ARBMACRO} ] ; then |
---|
118 | echo "Directory $ARBMACRO not found - creating ..." |
---|
119 | mkdir ${ARBMACRO} |
---|
120 | fi |
---|
121 | |
---|
122 | if [ "X$GDE_HELP_DIR" = "X" ] ; then |
---|
123 | GDE_HELP_DIR="$ARBHOME/GDEHELP" |
---|
124 | export GDE_HELP_DIR |
---|
125 | fi |
---|
126 | |
---|
127 | # set default command-tool used by ARB |
---|
128 | ARB_XTERM=${ARB_XTERM:-xterm -sl 1000 -sb -geometry 120x50} |
---|
129 | export ARB_XTERM |
---|
130 | ARB_XCMD=${ARB_XCMD:-$ARB_XTERM -e} |
---|
131 | export ARB_XCMD |
---|
132 | |
---|
133 | # save LD_LIBRARY_PATH |
---|
134 | ARB_LIBRARY_PATH="${LD_LIBRARY_PATH}" |
---|
135 | export ARB_LIBRARY_PATH |
---|
136 | |
---|
137 | if [ "$args" = "shell" ]; then |
---|
138 | echo "Opening an ARB shell" |
---|
139 | sh |
---|
140 | else |
---|
141 | if [ "$1" = "trace" ]; then |
---|
142 | shift |
---|
143 | $ARBHOME/SH/arb_trace $* |
---|
144 | else |
---|
145 | echo "Please wait while the program ARB is starting ....." |
---|
146 | (arb_ntree $args;arb_clean >/dev/null 2>&1;echo ARB done) & |
---|
147 | fi |
---|
148 | fi |
---|
149 | |
---|