Fix unexpected script_path behaviour
When one calls the build.sh
scripts with bash instead of the shebang
$script_path
contains the filepath, not the parent dir:
# cd /path
# grep -A2 script_path= build.sh
script_path=$(readlink -f "${0%/*}")
echo "$script_path"
exit 0
# ./build.sh
/path
# bash build.sh
/path/build.sh
This commit fixes that:
# grep -A2 script_path= build.sh
script_path="$( cd -P "$( dirname "$(readlink -f "$0")" )" && pwd )"
echo "$script_path"
exit 0
# ./build.sh
/path
# bash build.sh
/path