fabrice guichard
fabrice guichard

Reputation: 11

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.

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)

what i have forgotten?

thanks

Upvotes: 0

Views: 161

Answers (1)

eckenrod
eckenrod

Reputation: 529

The postinstall script does not run in any user context, and therefore doesn't inherit a given user's $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.

Upvotes: 1

Related Questions