From 44a1fa418e4251486ac811d1f8a2db99847f69b5 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 23 Sep 2009 16:44:10 +0100 Subject: Use full paths to all system utilities Otherwise you run the risk of not running the exact version / make of the utility you planned. Fixes Homebrew/homebrew#48 Really we need to do this formula too, so I guess a make and cmake function are on the way… --- Library/Homebrew/brew.h.rb | 2 +- Library/Homebrew/brewkit.rb | 2 +- Library/Homebrew/download_strategy.rb | 8 ++++---- Library/Homebrew/formula.rb | 8 ++++---- Library/Homebrew/unittest.rb | 2 +- Library/Homebrew/utils.rb | 24 ++++++++++++------------ 6 files changed, 23 insertions(+), 23 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb index 7a5e55fea..532e5b611 100644 --- a/Library/Homebrew/brew.h.rb +++ b/Library/Homebrew/brew.h.rb @@ -95,7 +95,7 @@ def info name require 'formula' user='' - user=`git config --global github.user`.chomp if system "which git > /dev/null" + user=`git config --global github.user`.chomp if system "/usr/bin/which -s git" user='mxcl' if user.empty? # FIXME it would be nice if we didn't assume the default branch is master history="http://github.com/#{user}/homebrew/commits/master/Library/Formula/#{Formula.path(name).basename}" diff --git a/Library/Homebrew/brewkit.rb b/Library/Homebrew/brewkit.rb index 132bda851..91ea9fa64 100644 --- a/Library/Homebrew/brewkit.rb +++ b/Library/Homebrew/brewkit.rb @@ -187,5 +187,5 @@ def inreplace(path, before, after) after.gsub! "$", "\\$" # FIXME use proper Ruby for teh exceptions! - safe_system "perl", "-pi", "-e", "s/#{before}/#{after}/g", path + safe_system "/usr/bin/perl", "-pi", "-e", "s/#{before}/#{after}/g", path end diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 0c89c1f2b..58e5b197b 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -51,11 +51,11 @@ class HttpDownloadStrategy \033[0;0;1m #{title}\033[0;0m" puts *sput unless sput.empty? end @@ -59,12 +59,12 @@ end # Kernel.system but with exceptions def safe_system cmd, *args puts "#{cmd} #{args*' '}" if ARGV.verbose? - exec_success=Kernel.system cmd, *args + exec_success = Kernel.system cmd, *args # some tools, eg. tar seem to confuse ruby and it doesn't propogate the # CTRL-C interrupt to us too, so execution continues, but the exit code os # still 2 so we raise our own interrupt raise Interrupt, cmd if $?.termsig == 2 - unless exec_success and $?.success? + unless exec_success puts "Exit code: #{$?}" raise ExecutionError.new(cmd, args) end @@ -75,23 +75,23 @@ def curl *args end def puts_columns items, cols = 4 - items = items.join("\n") if items.is_a?(Array) - items.concat("\n") unless items.empty? if $stdout.tty? - width=`stty size`.chomp.split(" ").last - IO.popen("pr -#{cols} -t", "w"){|io| io.write(items) } + items = items.join("\n") if items.is_a?(Array) + items.concat("\n") unless items.empty? + width=`/bin/stty size`.chomp.split(" ").last + IO.popen("/usr/bin/pr -#{cols} -t", "w"){|io| io.write(items) } else - items.each { |i| $stdout.write(i) } + puts *items end end def exec_editor *args editor=ENV['EDITOR'] if editor.nil? - if system "which -s mate" and $?.success? + if system "/usr/bin/which -s mate" editor='mate' else - editor='vim' + editor='/usr/bin/vim' end end # we split the editor because especially on mac "mate -w" is common @@ -103,9 +103,9 @@ end # provide an absolute path to a command or this function will search the PATH def arch_for_command cmd archs = [] - cmd = `which #{cmd}` if not Pathname.new(cmd).absolute? + cmd = `/usr/bin/which #{cmd}` if not Pathname.new(cmd).absolute? - IO.popen("file #{cmd}").readlines.each do |line| + IO.popen("/usr/bin/file #{cmd}").readlines.each do |line| case line when /Mach-O executable ppc/ archs << :ppc7400 -- cgit v1.2.3