Skip to content

Instantly share code, notes, and snippets.

@jrabbit
Created January 21, 2011 08:22
Show Gist options
  • Save jrabbit/789415 to your computer and use it in GitHub Desktop.
Save jrabbit/789415 to your computer and use it in GitHub Desktop.
Clean the $PATH then return it to normal. Make homebrew more harmonious with Fink et al.
diff --git a/bin/brew b/bin/brew
index 4ec64f0..79a1fb4 100755
--- a/bin/brew
+++ b/bin/brew
@@ -11,7 +11,11 @@ require 'pathname'
HOMEBREW_LIBRARY_PATH = (Pathname.new(__FILE__).realpath.dirname.parent+"Library/Homebrew").to_s
$:.unshift(HOMEBREW_LIBRARY_PATH)
require 'global'
-
+def path_clean
+ oldpath = ENV['PATH']
+ ENV['PATH'] = '/usr/bin:/bin:/sbin:/usr/sbin:/opt/X11/bin:/usr/X11/bin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin/' + ':' + HOMEBREW_PREFIX + '/bin:' + HOMEBREW_PREFIX + '/share/npm/bin'
+ oldpath
+end
case ARGV.first
when '-h', '--help', '--usage', '-?', 'help', nil
puts ARGV.usage
@@ -72,7 +76,7 @@ MacPorts or Fink? #{macports_or_fink_installed?}
X11 installed? #{x11_installed?}
EOS
end
-
+oldpath = path_clean
begin
require 'brew.h'
@@ -403,3 +407,4 @@ rescue Exception => e
puts e.backtrace
exit 1
end
+ENV['PATH'] = oldpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment