[英]How can I check for the presence of adb in an environment variable in a pretinstall or postinstall script for osx?
i want to check if adb is already set on variable path before to do an export like export PATH=$PATH:~/.android-sdk-macosx/platform-tools/
in the installation of the package.我想检查 adb 是否已经在变量路径上设置,然后在包的安装中进行像
export PATH=$PATH:~/.android-sdk-macosx/platform-tools/
这样的导出。
i try with a condition like that我尝试在这样的条件下
if ! command -v ADB &> /dev/null
then
echo "ADB could not be found"> /tmp/my_postinstall.log
else
echo "ADB is found"> /tmp/my_postinstall.log
fi
it's working in the terminal, but not the postinstall script (which is executable)它在终端中工作,但不是 postinstall 脚本(它是可执行的)
what i have forgotten?我忘记了什么?
thanks谢谢
The postinstall script does not run in any user context, and therefore doesn't inherit a given user's $PATH
. postinstall 脚本不会在任何用户上下文中运行,因此不会继承给定用户的
$PATH
。 Running source /Users/username/.bash_profile
will update the $PATH
your script sees to match that of the user's you want to check.运行
source /Users/username/.bash_profile
将更新您的脚本看到的$PATH
以匹配您要检查的用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.