tex/setuptex
包含需要当前路径的代码(通常是例如,例如
tex/setuptex
,
$HOME/context
等)。 代码看起来像这样:
/opt/context
通常运行此操作以更新当前环境,并使用各种环境变量运行上下文,并使用# 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
.。
在BusyBox(例如在Alpine Linux上),the是
. path/tex/setuptex
,这并不明显是正确的方法是什么。 将此行添加到脚本:
$SCRIPTPATH
Yields:
ScriptPathSH ::
相似
没有任何东西可以用/
echo "SCRIPTPATH $0 : $1 : $2"
env
。所以我不确定从哪里开始。
如何复制一个通常用于获取当前执行脚本的路径的功能?
从Henri Menke(通过电子邮件) -
标准Posix SH无法可靠地检测到脚本的源调用。 Busybox使用下面的Posix SH,因此受到相同的限制。看 详细的stackoverflow:如何在posix sh中获取脚本目录?