Created
January 31, 2017 17:09
-
-
Save alberthdev/085fbc0f0fc703534fd4164dd30f6181 to your computer and use it in GitHub Desktop.
Environment Loading Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Environment Loading Script by alberthdev | |
# To use, run: | |
# source load_env.sh | |
APP="arm-eabi (32-bit) GCC Linaro" | |
CDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
grepstr() { printf "$2" | grep "$1" 2>&1 >/dev/null; return $?; } | |
patherr() { echo "ERROR: Duplicate $1 path detected."; echo "You may already have this path loaded."; exit 1; } | |
die() { echo -e "$1"; exit 1; } | |
grepstr "$CDIR" "$PATH" && patherr "binary" | |
grepstr "$CDIR" "$LD_LIBRARY_PATH" && patherr "library" | |
export PATH="$PATH:$CDIR/bin" | |
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CDIR/lib" | |
echo "$APP loaded." | |
echo "If it doesn't seem to work, make sure that you are" | |
echo "actually sourcing this script. You can source this" | |
echo "script by running: source load_env.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment