summaryrefslogtreecommitdiff
path: root/qrouter.sh.in
blob: 2f4a204b43d131e532f87033607e3a4735527cb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
#
# For installation, put this file (qrouter.sh) in a standard executable path.
# Put startup script "qrouter.tcl" and shared library "qrouter.so"
# in ${QROUTER_LIB_DIR}.
#
# This script starts qrouter under the Tcl interpreter,
# reading commands from script qrouter.tcl which launches qrouter
# and retains the Tcl interactive interpreter.

# Parse for the argument "-noc[onsole]".  If it exists, run qrouter
# without the TkCon console.  Strip this argument from the argument list.

loclibdir=${QROUTER_LIB_DIR:=LIBDIR}
export QROUTER_LIB_DIR
QROUTER_WISH=WISH_EXE
export QROUTER_WISH

# Hacks for Cygwin
if [ ${TERM:=""} = "cygwin" ]; then
   export PATH="$PATH:$loclibdir"
   export DISPLAY=${DISPLAY:=":0"}
fi

# Don't use the console if "-noc[onsole]" was specified.
# Also, if "-i", "-h", or "-c" is specified, then this is
# a batch-mode operation and the console should be ignored.
TKCON=true
NULLG=
ARGS=""
for i in $@ ; do
   case $i in
      -noc*)
	TKCON=
	;;
      -nog*)
	NULLG=true
	TKCON=
	;;
      -c*)
	TKCON=
	ARGS="$ARGS $i"
	;;
      -i* | -h*)
	NULLG=true
	TKCON=
	ARGS="$ARGS $i"
	;;
      *)
	ARGS="$ARGS $i"
	;;
   esac
done

set -- junk $ARGS
shift

if [ $TKCON ]; then

   exec /usr/bin/tkcon \
	-eval "source ${loclibdir}/console.tcl" \
	-slave "package require Tk; set argc $#; set argv [list $*]; \
	source ${loclibdir}/qrouter.tcl"
else

#
# Run the stand-in for wish (qrouterexec), which acts exactly like "wish"
# except that it replaces ~/.wishrc with qrouter.tcl.  This executable is
# *only* needed when running without the console; the console itself is
# capable of sourcing the startup script.
#
   if [ $NULLG ]; then
      exec ${loclibdir}/qrouternullg -- $@
   else
      exec ${loclibdir}/qrouterexec -- $@
   fi
fi