In ConTeXt standalone, the file tex/setuptex
contains code that needs the current path of tex/setuptex
(which is usually e.g. $HOME/context
, /opt/context
, etc.). The code looks like this:
# this resolves to path of the setuptex script
# We use $0 for determine the path to the script, except for:
# * bash where $0 always is bash; here we use BASH_SOURCE
# * ksh93 where we use ${.sh.file}
# Thanks to Vasile Gaburici and Alessandro Perucchi for reporting this
# * http://www.ntg.nl/pipermail/ntg-context/2008/033953.html
# * http://www.ntg.nl/pipermail/ntg-context/2012/068658.html
if [ z"$BASH_SOURCE" != z ]; then
SCRIPTPATH="$BASH_SOURCE"
elif [ z"$KSH_VERSION" != z ]; then
SCRIPTPATH="${.sh.file}"
else
SCRIPTPATH="$0"
fi
One usually runs this to update the current environment with an assortment of environment variables needed to run ConTeXt, with . path/tex/setuptex
.
In BusyBox (on e.g. Alpine Linux), the $SCRIPTPATH
is /
, and it's not apparent what the correct way to get the path would be. Adding this line to the script:
echo "SCRIPTPATH $0 : $1 : $2"
yields:
SCRIPTPATH sh : :
Similarly env
yields nothing with setuptex
.
So I'm not certain where to start.
How does one replicate the *sh
functionality one ordinarily uses to obtain the path of the currently executing script?
. /path/to/context
) rather than running it (sh /path/to/context
). I don't have a solution for you, but you could consider workaround a workaround like:. /path/to/context /path/to/context
will store the answer (potentially relative to$PWD
) in$1
.
is in the instructions from ConTeXt, which a lot of people would be familiar with..
orsource
due to importing some combination of environment, functions, and/or aliases, which you can't pull in via new shells. That's why all I can offer is that awkward workaround. This may be a busybox bug.