Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

brew: use a shell wrapper script for brew

This reverts commit dfd4dd1.

Fixes the problems from #17683 and #17685.
  • Loading branch information...
commit ba2b2356115c0106dc5ab7c555ed4e0f2d054017 1 parent 8b9d620
@mikemcquaid mikemcquaid authored
Showing with 26 additions and 1 deletion.
  1. +2 −1  Library/brew.rb
  2. +24 −0 bin/brew
View
3  Library/brew.rb
@@ -3,7 +3,8 @@
std_trap = trap("INT") { exit! 130 } # no backtrace thanks
-HOMEBREW_BREW_FILE = ENV['HOMEBREW_BREW_FILE'] = File.expand_path(__FILE__)
+HOMEBREW_BREW_FILE = ENV['HOMEBREW_BREW_FILE']
+HOMEBREW_BREW_FILE = ENV['HOMEBREW_BREW_FILE'] ||= File.expand_path(__FILE__)
if ARGV == %w{--prefix}
puts File.dirname(File.dirname(HOMEBREW_BREW_FILE))
View
24 bin/brew
@@ -0,0 +1,24 @@
+#!/bin/sh
+BREW_FILE_DIRECTORY=$(dirname "$0")
+BREW_FILE_DIRECTORY=$(cd "$BREW_FILE_DIRECTORY" && pwd -P)
+
+BREW_FILENAME=$(basename "$0")
+export HOMEBREW_BREW_FILE="$BREW_FILE_DIRECTORY/$BREW_FILENAME"
+
+BREW_SYMLINK=$(readlink $0)
+if [ -n "$BREW_SYMLINK" ]
+then
+ BREW_SYMLINK_DIRECTORY=$(dirname "$BREW_SYMLINK")
+ BREW_FILE_DIRECTORY=$(cd "$BREW_FILE_DIRECTORY" &&
+ cd "$BREW_SYMLINK_DIRECTORY" && pwd -P)
+fi
+
+BREW_LIBRARY_DIRECTORY=$(cd "$BREW_FILE_DIRECTORY"/../Library && pwd -P)
+
+BREW_SYSTEM=$(uname -s | tr "[:upper:]" "[:lower:]")
+if [ "$BREW_SYSTEM" = "darwin" ]
+then
+ exec "$BREW_LIBRARY_DIRECTORY/brew.rb" "$@"
+else
+ exec ruby -W0 "$BREW_LIBRARY_DIRECTORY/brew.rb" "$@"
+fi
Please sign in to comment.
Something went wrong with that request. Please try again.