summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/bundle7
-rw-r--r--lib/bundler/friendly_errors.rb6
-rw-r--r--spec/bundler/cli_rspec.rb5
3 files changed, 17 insertions, 1 deletions
diff --git a/bin/bundle b/bin/bundle
index d2c62045bc..fc2aca105a 100755
--- a/bin/bundle
+++ b/bin/bundle
@@ -17,4 +17,9 @@ end
require 'bundler/cli'
require 'bundler/friendly_errors'
-Bundler.with_friendly_errors { Bundler::CLI.start }
+Bundler.with_friendly_errors {
+ # Set debug flag so we can rescue Thor::error's
+ # and set the correct exit code.
+ ENV["THOR_DEBUG"] = "1"
+ Bundler::CLI.start
+}
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index 1a8b9aa384..f5fabfec3e 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -5,6 +5,12 @@ module Bundler
Bundler.ui.error e.message, :wrap => true
Bundler.ui.trace e
exit e.status_code
+ rescue Thor::UndefinedCommandError => e
+ Bundler.ui.error e.message
+ exit 15
+ rescue Thor::Error => e
+ Bundler.ui.error e.message
+ exit 1
rescue LoadError => e
raise e unless e.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/
Bundler.ui.error "\nCould not load OpenSSL."
diff --git a/spec/bundler/cli_rspec.rb b/spec/bundler/cli_rspec.rb
index baf2f9554b..e476c74498 100644
--- a/spec/bundler/cli_rspec.rb
+++ b/spec/bundler/cli_rspec.rb
@@ -6,4 +6,9 @@ describe 'bundle executable' do
bundle '--invalid_argument', :exitstatus => true
expect(exitstatus).to_not be_zero
end
+
+ it 'returns non-zero exit status when passed unrecognized task' do
+ bundle 'unrecognized-tast', :exitstatus => true
+ expect(exitstatus).to_not be_zero
+ end
end