diff options
| author | Mike McQuaid | 2016-09-01 07:46:58 +0100 |
|---|---|---|
| committer | GitHub | 2016-09-01 07:46:58 +0100 |
| commit | 6622b565ee38de1cd97f5c7b20fa62b481a1ec9b (patch) | |
| tree | 15bbbd19da5b9b096d0e02162fd72e4fd4fc618c /Library/Homebrew/shims | |
| parent | 7b2798cb3509b8c6fb49487b04ec423d287262d0 (diff) | |
| parent | 408ac6088f0cdb32c6c033df4f4c18b8ce7829c1 (diff) | |
| download | brew-6622b565ee38de1cd97f5c7b20fa62b481a1ec9b.tar.bz2 | |
Merge pull request #801 from MikeMcQuaid/git-shim-realpath
scm/git: make --homebrew=print-path use realpath.
Diffstat (limited to 'Library/Homebrew/shims')
| -rwxr-xr-x | Library/Homebrew/shims/scm/git | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/Library/Homebrew/shims/scm/git b/Library/Homebrew/shims/scm/git index 2a95b0181..eedca486b 100755 --- a/Library/Homebrew/shims/scm/git +++ b/Library/Homebrew/shims/scm/git @@ -9,15 +9,23 @@ quiet_safe_cd() { 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() { local path="$1" local dir - local base local dest - dir="$(quiet_safe_cd "${path%/*}/" && pwd -P)" - base="${path##*/}" - path="$dir/$base" + dir="$(absdir "$path")" + path="$(dirbasepath "$dir" "$path")" while [[ -L "$path" ]] do @@ -28,9 +36,8 @@ realpath() { else path="$dir/$dest" fi - dir="$(quiet_safe_cd "${path%/*}/" && pwd -P)" - base="${path##*/}" - path="$dir/$base" + dir="$(absdir "$path")" + path="$(dirbasepath "$dir" "$path")" done echo "$path" @@ -58,7 +65,9 @@ safe_exec() { fi if [[ "$HOMEBREW" = "print-path" ]] then - echo "$arg0" + local dir="$(quiet_safe_cd "${arg0%/*}/" && pwd)" + local path="$(dirbasepath "$dir" "$arg0")" + echo "$path" exit fi exec "$@" |
