Skip to content

Commit

Permalink
fix realpath command
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1thas committed Oct 17, 2023
1 parent 3ab55f7 commit caf09b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/lib/modules/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 4 additions & 4 deletions src/lib/modules/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit caf09b9

Please sign in to comment.