提交 686f4439 编写于 作者: M Mislav Marohnić

fixes shellwords usage for ruby 1.8.6 compat

上级 f4aee7e5
......@@ -724,8 +724,8 @@ help
def expand_alias(cmd)
if expanded = git_alias_for(cmd)
if expanded.index('!') != 0
require 'shellwords' unless expanded.respond_to? :shellsplit
expanded.shellsplit
require 'shellwords' unless defined?(::Shellwords)
Shellwords.shellwords(expanded)
end
end
end
......
......@@ -15,14 +15,16 @@ module Hub
end
def to_exec(args)
args = args.shellsplit if args.respond_to? :shellsplit
args = Shellwords.shellwords(args) if args.respond_to? :to_str
Array(executable) + Array(args)
end
end
# Caches output when shelling out to git
GIT_CONFIG = ShellOutCache.new(ENV['GIT'] || 'git') do |cache, cmd|
result = %x{#{cache.to_exec(cmd).shelljoin}}.chomp
full_cmd = cache.to_exec(cmd)
cmd_string = full_cmd.respond_to?(:shelljoin) ? full_cmd.shelljoin : full_cmd.join(' ')
result = %x{#{cmd_string}}.chomp
cache[cmd] = $?.success? && !result.empty? ? result : nil
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册