aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Afanasjew2015-11-23 21:31:16 +0100
committerMartin Afanasjew2015-12-01 21:36:05 +0100
commitf1a7e51d2a12f895bd696329574b7fc901e2e05c (patch)
treea5d5a7a5287f4b3a21d1176915981d49806a1e6a
parent5b828d4265adf06adc4eff6472a89038035ae833 (diff)
downloadbrew-f1a7e51d2a12f895bd696329574b7fc901e2e05c.tar.bz2
bin/brew: avoid unnecessary 'readlink' invocation
For typical installations where `brew` is not a symbolic link, this reduces the number of processes that need to be spawned. Closes Homebrew/homebrew#46269. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
-rwxr-xr-xbin/brew4
1 files changed, 2 insertions, 2 deletions
diff --git a/bin/brew b/bin/brew
index 37f918b56..9cdeb1a10 100755
--- a/bin/brew
+++ b/bin/brew
@@ -6,9 +6,9 @@ chdir() {
BREW_FILE_DIRECTORY="$(chdir "${0%/*}" && pwd -P)"
HOMEBREW_BREW_FILE="$BREW_FILE_DIRECTORY/${0##*/}"
-BREW_SYMLINK="$(readlink "$0")"
-if [ -n "$BREW_SYMLINK" ]
+if [ -L "$HOMEBREW_BREW_FILE" ]
then
+ BREW_SYMLINK="$(readlink "$HOMEBREW_BREW_FILE")"
BREW_SYMLINK_DIRECTORY="$(dirname "$BREW_SYMLINK")"
BREW_FILE_DIRECTORY="$(chdir "$BREW_FILE_DIRECTORY" &&
chdir "$BREW_SYMLINK_DIRECTORY" && pwd -P)"