diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-04-14 19:29:44 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-04-14 22:40:20 -0500 |
commit | d928822a17fef3713fd9501fa7a73aa727d08822 (patch) | |
tree | 85f874e509b3ba1b70138c69e31e351eafd892b5 | |
parent | 3a09448d8b060f2688dbc73bfa1eb08e1bd126f3 (diff) | |
download | bundler-seg-exec-load-at-exit.tar.gz |
[Exec] Allow executables to exit non-zero via at_exitseg-exec-load-at-exit
-rw-r--r-- | lib/bundler/cli/exec.rb | 3 | ||||
-rw-r--r-- | spec/commands/exec_spec.rb | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index 3ef2492c2f..00e42c9b83 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -21,7 +21,7 @@ module Bundler validate_cmd! SharedHelpers.set_bundle_environment if bin_path = Bundler.which(cmd) - kernel_load(bin_path, *args) if ruby_shebang?(bin_path) + return kernel_load(bin_path, *args) if ruby_shebang?(bin_path) # First, try to exec directly to something in PATH kernel_exec([bin_path, cmd], *args) else @@ -61,7 +61,6 @@ module Bundler Bundler.ui = nil require "bundler/setup" Kernel.load(file) - exit rescue SystemExit raise rescue Exception => e # rubocop:disable Lint/RescueException diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 29f5927c14..e2ae0aabbb 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -395,7 +395,7 @@ describe "bundle exec" do subject { bundle "exec #{path} arg1 arg2", :expect_err => true } shared_examples_for "it runs" do - it "like a normally executed executable like a normally executed executable" do + it "like a normally executed executable" do subject expect(exitstatus).to eq(exit_code) if exitstatus expect(err).to eq(expected_err) @@ -450,5 +450,12 @@ describe "bundle exec" do it_behaves_like "it runs" end + + context "when the executable exits non-zero via at_exit" do + let(:executable) { super() + "\n\nat_exit { $! ? raise($!) : exit(1) }" } + let(:exit_code) { 1 } + + it_behaves_like "it runs" + end end end |