From dec2fff0bf4a5160837e6c1b92470336a60c2a98 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Wed, 19 Dec 2018 20:00:16 +0700 Subject: [PATCH] Support coreutils on Mac, which provides a greadlink command that supports the -f option (brew install coreutils) --- lib/git/shell_shortcuts.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/git/shell_shortcuts.sh b/lib/git/shell_shortcuts.sh index 49d9b81..54f79ce 100644 --- a/lib/git/shell_shortcuts.sh +++ b/lib/git/shell_shortcuts.sh @@ -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'