diff --git a/src/lib/modules/base.sh b/src/lib/modules/base.sh index 6e07862..53088c3 100644 --- a/src/lib/modules/base.sh +++ b/src/lib/modules/base.sh @@ -16,4 +16,5 @@ TOTAL_N_GENERATED_FILES=0 BASE_FOLDER="$PWD" FILE_ATTR_NAME="com.dropbox.ignored" [[ $MACHINE == Darwin ]] && GREP_CMD="ggrep" || GREP_CMD="grep" +[[ $MACHINE == Darwin ]] && REALPATH_CMD="$(brew --prefix)/bin/realpath" || GREP_CMD="realpath" [[ $MACHINE == Darwin ]] && DIFF_CMD="$(brew --prefix)/bin/diff" || DIFF_CMD="diff" diff --git a/src/lib/modules/utils.sh b/src/lib/modules/utils.sh index eec6de1..5d33340 100644 --- a/src/lib/modules/utils.sh +++ b/src/lib/modules/utils.sh @@ -86,8 +86,8 @@ check_input() { # Relative path. ####################################### get_absolute_path() { - if command -v realpath &>/dev/null; then - realpath "$1" + if command -v "$REALPATH_CMD" &>/dev/null; then + "$REALPATH_CMD" "$1" else python -c 'import os.path, sys;print(os.path.abspath(sys.argv[1]))' "$1" fi @@ -100,8 +100,8 @@ get_absolute_path() { # Base Absolute path. ####################################### get_relative_path() { - if command -v realpath &>/dev/null; then - realpath --relative-to="${2-$PWD}" "$1" + if command -v "$REALPATH_CMD" &>/dev/null; then + "$REALPATH_CMD" --relative-to="${2-$PWD}" "$1" else python -c 'import os.path, sys;print(os.path.relpath(sys.argv[1],sys.argv[2]))' "$1" "${2-$PWD}" fi