Fallback to readlink -f on macOS

BSD coreutils readlink doesn't have -f option, so
adding a Python one-liner feedback to eval symlinks/homedir.
Fixes #8.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2017-05-17 09:35:35 -07:00
parent 7e10232fdd
commit 8e413fc8ac
No known key found for this signature in database
GPG Key ID: 5C02521D7B216AD6
2 changed files with 6 additions and 2 deletions

View File

@ -21,7 +21,9 @@
set -eou pipefail
IFS=$'\n\t'
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
SCRIPT_DIR="$(dirname "$( readlink -f "${0}" 2>/dev/null || \
python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "${0}" )")"
if [[ -f "${SCRIPT_DIR}/utils.bash" ]]; then
source "${SCRIPT_DIR}/utils.bash"
else

4
kubens
View File

@ -21,7 +21,9 @@
set -eou pipefail
IFS=$'\n\t'
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
SCRIPT_DIR="$(dirname "$( readlink -f "${0}" 2>/dev/null || \
python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "${0}" )")"
if [[ -f "${SCRIPT_DIR}/utils.bash" ]]; then
source "${SCRIPT_DIR}/utils.bash"
else