summaryrefslogtreecommitdiff
path: root/lib/bundler/gem_helper.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2017-09-19 11:26:43 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2017-09-19 13:46:48 +0900
commitef2471a3be9aa4efebd93c5fadb316471e575015 (patch)
treebc67e83c756904194e6247be4564f1c32a9b834c /lib/bundler/gem_helper.rb
parent9272e1a48738d2de6c9e00a36cd055758e4516ae (diff)
downloadbundler-ef2471a3be9aa4efebd93c5fadb316471e575015.tar.gz
Support 1.8
Diffstat (limited to 'lib/bundler/gem_helper.rb')
-rw-r--r--lib/bundler/gem_helper.rb29
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index cca7287c4b..3458a2adda 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -192,13 +192,28 @@ module Bundler
[outbuf, (status && status.exitstatus) || -1]
end
- def sh_with_status(cmd, &block)
- Bundler.ui.debug(cmd)
- SharedHelpers.chdir(base) do
- outbuf = IO.popen(cmd, err: [:child, :out], &:read)
- status = $?
- block.call(outbuf) if status.success? && block
- [outbuf, status]
+ if RUBY_VERSION >= "1.9"
+ def sh_with_status(cmd, &block)
+ Bundler.ui.debug(cmd)
+ SharedHelpers.chdir(base) do
+ outbuf = IO.popen(cmd, :err => [:child, :out], &:read)
+ status = $?
+ block.call(outbuf) if status.success? && block
+ [outbuf, status]
+ end
+ end
+ else
+ def sh_with_status(cmd, &block)
+ cmd = cmd.shelljoin if cmd.respond_to?(:shelljoin)
+ cmd += " 2>&1"
+ outbuf = String.new
+ Bundler.ui.debug(cmd)
+ SharedHelpers.chdir(base) do
+ outbuf = `#{cmd}`
+ status = $?
+ block.call(outbuf) if status.success? && block
+ [outbuf, status]
+ end
end
end