Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Exit with bad exit code on command failures.

  • Loading branch information...
commit 7cc4e83a06f384116a7d9b71e303c062d96bdb45 1 parent a6b188b
@mikemcquaid mikemcquaid authored committed
View
2  Library/Homebrew/cmd/audit.rb
@@ -420,7 +420,7 @@ def audit
if errors
puts "#{problem_count} problems in #{brew_count} brews"
- exit 1
+ Homebrew.failed = true
end
end
end
View
12 Library/Homebrew/cmd/bottle.rb
@@ -4,8 +4,16 @@
module Homebrew extend self
def bottle_formula f
- return onoe "Formula not installed: #{f.name}" unless f.installed?
- return onoe "Formula not installed with '--build-bottle': #{f.name}" unless built_bottle? f
+ unless f.installed?
+ onoe "Formula not installed: #{f.name}"
+ Homebrew.failed = true
+ return
+ end
+
+ unless built_bottle? f
+ onoe "Formula not installed with '--build-bottle': #{f.name}"
+ Homebrew.failed = true
+ end
directory = Pathname.pwd
filename = bottle_filename f
View
9 Library/Homebrew/cmd/doctor.rb
@@ -879,22 +879,19 @@ def check_os_version
module Homebrew extend self
def doctor
- raring_to_brew = true
-
checks = Checks.new
checks.methods.select{ |method| method =~ /^check_/ }.sort.each do |method|
out = checks.send(method)
unless out.nil? or out.empty?
- puts unless raring_to_brew
+ puts unless Homebrew.failed?
lines = out.to_s.split('\n')
opoo lines.shift
puts lines
- raring_to_brew = false
+ Homebrew.failed = true
end
end
- puts "Your system is raring to brew." if raring_to_brew
- exit raring_to_brew ? 0 : 1
+ puts "Your system is raring to brew." unless Homebrew.failed?
end
end
View
1  Library/Homebrew/cmd/install.rb
@@ -77,6 +77,7 @@ def install_formulae formulae
fi.finish
rescue CannotInstallFormulaError => e
onoe e.message
+ Homebrew.failed = true
end
end
end
View
5 Library/Homebrew/cmd/test.rb
@@ -13,21 +13,24 @@ def test
# Cannot test uninstalled formulae
unless f.installed?
puts "#{f.name} not installed"
+ Homebrew.failed = true
next
end
# Cannot test formulae without a test method
unless f.respond_to? :test
puts "#{f.name} defines no test"
+ Homebrew.failed = true
next
end
puts "Testing #{f.name}"
begin
# tests can also return false to indicate failure
- puts "#{f.name}: failed" if f.test == false
+ raise if f.test == false
rescue
puts "#{f.name}: failed"
+ Homebrew.failed = true
end
end
end
View
1  Library/Homebrew/cmd/uninstall.rb
@@ -35,5 +35,6 @@ def uninstall
rescue MultipleVersionsInstalledError => e
onoe e
puts "Use `brew remove --force #{e.name}` to remove all versions."
+ Homebrew.failed = true
end
end
View
2  Library/Homebrew/cmd/upgrade.rb
@@ -67,9 +67,11 @@ def upgrade_formula f
installer.finish
rescue CannotInstallFormulaError => e
onoe e
+ Homebrew.failed = true
rescue BuildError => e
e.dump
puts
+ Homebrew.failed = true
ensure
# restore previous installation state if build failed
outdated_keg.link if outdated_keg and not f.installed? rescue nil
View
3  Library/Homebrew/global.rb
@@ -79,6 +79,9 @@ def mkpath
require 'fileutils'
module Homebrew extend self
include FileUtils
+
+ attr_accessor :failed
+ alias_method :failed?, :failed
end
FORMULA_META_FILES = %w[README README.md ChangeLog CHANGES COPYING LICENSE LICENCE COPYRIGHT AUTHORS]
View
2  bin/brew
@@ -112,4 +112,6 @@ rescue Exception => e
puts " #{Tty.em}#{ISSUES_URL}#{Tty.reset}"
puts e.backtrace
exit 1
+else
+ exit 1 if Homebrew.failed?
end
Please sign in to comment.
Something went wrong with that request. Please try again.