bin/brew: separate variable assignment and export

This very slightly reduces duplication and the risk of inconsistency by
exporting in one branch, but not the other. By putting all the `export`
statements right before the `exec` it is more obvious what is passed on.
This commit is contained in:
Martin Afanasjew 2015-11-20 20:52:29 +01:00
parent 73a7889de5
commit 8f175cb03c

View File

@ -4,7 +4,7 @@ chdir() {
} }
BREW_FILE_DIRECTORY="$(chdir "${0%/*}" && pwd -P)" BREW_FILE_DIRECTORY="$(chdir "${0%/*}" && pwd -P)"
export HOMEBREW_BREW_FILE="$BREW_FILE_DIRECTORY/${0##*/}" HOMEBREW_BREW_FILE="$BREW_FILE_DIRECTORY/${0##*/}"
BREW_SYMLINK="$(readlink "$0")" BREW_SYMLINK="$(readlink "$0")"
if [ -n "$BREW_SYMLINK" ] if [ -n "$BREW_SYMLINK" ]
@ -31,10 +31,13 @@ then
BREW_SYSTEM="$(uname -s | tr "[:upper:]" "[:lower:]")" BREW_SYSTEM="$(uname -s | tr "[:upper:]" "[:lower:]")"
if [ "$BREW_SYSTEM" = "darwin" ] if [ "$BREW_SYSTEM" = "darwin" ]
then then
export HOMEBREW_RUBY_PATH="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby" HOMEBREW_RUBY_PATH="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby"
else else
export HOMEBREW_RUBY_PATH="$(which ruby)" HOMEBREW_RUBY_PATH="$(which ruby)"
fi fi
fi fi
export HOMEBREW_BREW_FILE
export HOMEBREW_RUBY_PATH
exec "$HOMEBREW_RUBY_PATH" -W0 "$BREW_LIBRARY_DIRECTORY/brew.rb" "$@" exec "$HOMEBREW_RUBY_PATH" -W0 "$BREW_LIBRARY_DIRECTORY/brew.rb" "$@"