2017-04-25 14:41:48 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
|
|
|
|
# For installation, put this file (magic.sh) in a known executable path.
|
|
|
|
|
# Put startup script "magic.tcl", shared library "tclmagic.so", and
|
|
|
|
|
# "wish" replacement "magicexec" in ${CAD_ROOT}/magic/tcl/.
|
|
|
|
|
#
|
|
|
|
|
# This script starts magic under the Tcl interpreter,
|
|
|
|
|
# reading commands from a special startup script which
|
|
|
|
|
# launches magic and retains the Tcl interactive interpreter.
|
|
|
|
|
|
|
|
|
|
# Parse for the argument "-c[onsole]". If it exists, run magic
|
|
|
|
|
# with the TkCon console. Strip this argument from the argument list.
|
|
|
|
|
|
2021-02-02 16:19:04 +01:00
|
|
|
TCL_MAG_DIR=${CAD_ROOT}/magic/tcl
|
|
|
|
|
if [ "${TCL_MAG_DIR}" = "/magic/tcl" ]; then
|
|
|
|
|
TCL_MAG_DIR=TCL_DIR
|
2020-10-05 07:51:37 +02:00
|
|
|
fi
|
2017-04-25 14:41:48 +02:00
|
|
|
TKCON=true
|
|
|
|
|
DNULL=
|
|
|
|
|
MAGIC_WISH=WISH_EXE
|
|
|
|
|
export MAGIC_WISH
|
|
|
|
|
|
|
|
|
|
# Hacks for Cygwin
|
|
|
|
|
if [ "`uname | cut -d_ -f1`" = "CYGWIN" ]; then
|
|
|
|
|
export PATH="$PATH:TCLLIB_DIR"
|
|
|
|
|
export DISPLAY=${DISPLAY:=":0"}
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Preserve quotes in arguments
|
|
|
|
|
arglist=''
|
|
|
|
|
for i in "$@" ; do
|
|
|
|
|
case $i in
|
|
|
|
|
-noc*) TKCON=;;
|
|
|
|
|
-dnull) DNULL=true;;
|
|
|
|
|
--version) TKCON=; DNULL=true;;
|
2022-02-25 15:56:22 +01:00
|
|
|
--commit) TKCON=; DNULL=true;;
|
2017-04-25 14:41:48 +02:00
|
|
|
--prefix) TKCON=; DNULL=true;;
|
|
|
|
|
*) arglist="$arglist${arglist:+ }\"${i//\"/\\\"}\"";;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ $TKCON ]; then
|
|
|
|
|
|
|
|
|
|
if [ $DNULL ]; then
|
2021-02-02 16:19:04 +01:00
|
|
|
exec $TCL_MAG_DIR/tkcon.tcl -eval "source $TCL_MAG_DIR/console.tcl" \
|
|
|
|
|
-slave "set argc $#; set argv [list $*]; source $TCL_MAG_DIR/magic.tcl"
|
2017-04-25 14:41:48 +02:00
|
|
|
else
|
2021-02-02 16:19:04 +01:00
|
|
|
exec $TCL_MAG_DIR/tkcon.tcl -eval "source $TCL_MAG_DIR/console.tcl" \
|
2017-04-25 14:41:48 +02:00
|
|
|
-slave "package require Tk; set argc $#; set argv [list $arglist]; \
|
2021-02-02 16:19:04 +01:00
|
|
|
source $TCL_MAG_DIR/magic.tcl"
|
2017-04-25 14:41:48 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Run the stand-in for wish (magicexec), which acts exactly like "wish"
|
|
|
|
|
# except that it replaces ~/.wishrc with magic.tcl. This executable is
|
|
|
|
|
# *only* needed when running without the console; the console itself is
|
|
|
|
|
# capable of sourcing the startup script.
|
|
|
|
|
#
|
|
|
|
|
# With option "-dnull" we set up for operation without Tk (simple interpreter
|
|
|
|
|
# only, efficient for running in batch mode).
|
|
|
|
|
#
|
|
|
|
|
if [ $DNULL ]; then
|
2021-02-02 16:19:04 +01:00
|
|
|
exec $TCL_MAG_DIR/magicdnull -nowrapper "$@"
|
2017-04-25 14:41:48 +02:00
|
|
|
else
|
2021-02-02 16:19:04 +01:00
|
|
|
exec $TCL_MAG_DIR/magicexec -- "$@"
|
2017-04-25 14:41:48 +02:00
|
|
|
fi
|
|
|
|
|
fi
|