historical/toontown-classic.git/panda/direct/directscripts/runPythonEmacs
2024-01-16 11:20:27 -06:00

42 lines
1.6 KiB
Bash

#! /bin/bash
# This script is designed to de-Cygwinify the project variables set by
# the ctattach scripts. If you aren't using ctattach (and you almost
# certainly won't be, unless you're a member of the VR Studio),
# there's no reason to use this script.
# First, de-Cygwinify the HOME variable. Since this variable is
# hardcoded, we can just do it.
HOME=`cygpath -w $HOME`
export HOME
# Now de-Cygwinify the package variables for all of the trees we are
# attached to, e.g. $DTOOL, $PANDA, $DIRECT, etc. These variable
# names are discovered by parsing the $CTPROJS variable, which is made
# up of a series of words like "DIRECT:personal PANDA:personal
# DTOOL:install"; we simply pull off each word and get the part
# preceding the colon.
# That gives us an indirect reference: we end up with a variable that
# contains, e.g., the string "DTOOL": the name of the variable we want
# to modify. Bash provides a way to read the value of an indirect
# reference: ${!varname} returns the variable named by the contents of
# $varname.
# However, bash doesn't provide a way to set the variable named by an
# indirect reference. But we can achieve this by using the env
# command, which accepts as a parameter a list of variables that
# should be reassigned, in the form "var1=value1 var2=value2 ...". So
# we just have to build up this string and pass it to the env command.
assign=""
for packageDef in $CTPROJS; do
packageVar=`echo $packageDef | sed 's/:.*$//'`
decyg=`cygpath -w ${!packageVar}`
assign="$assign $packageVar=$decyg"
done
# Now use the env command to pass all these assignments to emacs.
exec env $assign runemacs "$@"