Support coreutils on Mac, which provides a greadlink command that supports the -f option (brew install coreutils)

This commit is contained in:
Nathan Broadbent
2018-12-19 20:00:16 +07:00
parent 5bc863284b
commit dec2fff0bf

View File

@@ -99,11 +99,13 @@ if ! ls --color=auto > /dev/null 2>&1; then
_ls_bsd="BSD"
fi
# Test if readlink supports -f option, otherwise use perl (a bit slower)
if ! readlink -f / > /dev/null 2>&1; then
_abs_path_command=(perl -e 'use Cwd abs_path; print abs_path(shift)')
else
# Test if readlink supports -f option, test for greadlink on Mac, then fallback to perl
if \readlink -f / > /dev/null 2>&1; then
_abs_path_command=(readlink -f)
elif greadlink -f / > /dev/null 2>&1; then
_abs_path_command=(greadlink -f)
else
_abs_path_command=(perl -e 'use Cwd abs_path; print abs_path(shift)')
fi
# Function wrapper around 'll'