使用busybox

时间:2018-04-10 14:12:43

标签: shell sh posix busybox

在ConTeXt standalone中,文件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

通常使用. path/tex/setuptex运行此操作以使用运行ConTeXt所需的各种环境变量来更新当前环境。

在BusyBox中(例如在Alpine Linux上),$SCRIPTPATH/,并且不明白获取路径的正确方法是什么。将此行添加到脚本中:

echo "SCRIPTPATH $0 : $1 : $2"

的产率:

  

SCRIPTPATH sh ::

同样envsetuptex无关。

所以我不确定从哪里开始。

如何复制通常用于获取当前正在执行的脚本路径的*sh功能?

1 个答案:

答案 0 :(得分:0)

来自Henri Menke(通过电子邮件发送) -

  

标准POSIX sh无法可靠地检测脚本的源调用。   BusyBox在下面使用POSIX sh,因此受到同样的限制。看到   StackOverflow详细信息:how to get script directory in POSIX sh?

相关问题