Merge pull request #801 from MikeMcQuaid/git-shim-realpath
scm/git: make --homebrew=print-path use realpath.
This commit is contained in:
commit
6622b565ee
@ -17,10 +17,7 @@ source "$HOMEBREW_LIBRARY/Homebrew/utils/lock.sh"
|
|||||||
git() {
|
git() {
|
||||||
if [[ -z "$GIT_EXECUTABLE" ]]
|
if [[ -z "$GIT_EXECUTABLE" ]]
|
||||||
then
|
then
|
||||||
GIT_EXECUTABLE_RELATIVE="$("$HOMEBREW_LIBRARY/Homebrew/shims/scm/git" --homebrew=print-path)"
|
GIT_EXECUTABLE="$("$HOMEBREW_LIBRARY/Homebrew/shims/scm/git" --homebrew=print-path)"
|
||||||
GIT_EXECUTABLE_BASE="$(basename "$GIT_EXECUTABLE_RELATIVE")"
|
|
||||||
GIT_EXECUTABLE_DIR="$(cd "$(dirname "$GIT_EXECUTABLE_RELATIVE")" && pwd)"
|
|
||||||
GIT_EXECUTABLE="$GIT_EXECUTABLE_DIR/$GIT_EXECUTABLE_BASE"
|
|
||||||
fi
|
fi
|
||||||
"$GIT_EXECUTABLE" "$@"
|
"$GIT_EXECUTABLE" "$@"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,15 +9,23 @@ quiet_safe_cd() {
|
|||||||
cd "$1" >/dev/null || { echo "Error: failed to cd to $1" >&2; exit 1; }
|
cd "$1" >/dev/null || { echo "Error: failed to cd to $1" >&2; exit 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
absdir() {
|
||||||
|
quiet_safe_cd "${1%/*}/" && pwd -P
|
||||||
|
}
|
||||||
|
|
||||||
|
dirbasepath() {
|
||||||
|
local dir="$1"
|
||||||
|
local base="${2##*/}"
|
||||||
|
echo "$dir/$base"
|
||||||
|
}
|
||||||
|
|
||||||
realpath() {
|
realpath() {
|
||||||
local path="$1"
|
local path="$1"
|
||||||
local dir
|
local dir
|
||||||
local base
|
|
||||||
local dest
|
local dest
|
||||||
|
|
||||||
dir="$(quiet_safe_cd "${path%/*}/" && pwd -P)"
|
dir="$(absdir "$path")"
|
||||||
base="${path##*/}"
|
path="$(dirbasepath "$dir" "$path")"
|
||||||
path="$dir/$base"
|
|
||||||
|
|
||||||
while [[ -L "$path" ]]
|
while [[ -L "$path" ]]
|
||||||
do
|
do
|
||||||
@ -28,9 +36,8 @@ realpath() {
|
|||||||
else
|
else
|
||||||
path="$dir/$dest"
|
path="$dir/$dest"
|
||||||
fi
|
fi
|
||||||
dir="$(quiet_safe_cd "${path%/*}/" && pwd -P)"
|
dir="$(absdir "$path")"
|
||||||
base="${path##*/}"
|
path="$(dirbasepath "$dir" "$path")"
|
||||||
path="$dir/$base"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "$path"
|
echo "$path"
|
||||||
@ -58,7 +65,9 @@ safe_exec() {
|
|||||||
fi
|
fi
|
||||||
if [[ "$HOMEBREW" = "print-path" ]]
|
if [[ "$HOMEBREW" = "print-path" ]]
|
||||||
then
|
then
|
||||||
echo "$arg0"
|
local dir="$(quiet_safe_cd "${arg0%/*}/" && pwd)"
|
||||||
|
local path="$(dirbasepath "$dir" "$arg0")"
|
||||||
|
echo "$path"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user