def execute(command, redirects = {}, &block)
rin = redirects[:i] || redirects[:in] || redirects[:stdin] ||
redirects['stdin'] || redirects['i'] || redirects['in'] ||
redirects[0] || redirects['0']
if rin
tmp =
begin
Tempfile::new rand.to_s
rescue
Tempfile::new rand.to_s
end
begin
tmp.write(
if rin.respond_to? 'read'
rin.read
elsif rin.respond_to? 'to_s'
rin.to_s
else
rin
end
)
tmp.flush
command = "{ #{ command } ;} < #{ tmp.path }"
super(command, redirects, &block)
ensure
tmp.close! if tmp
end
else
super
end
end