class Session::Sh
def execute(command, redirects = {}, &block)
def execute(command, redirects = {}, &block) # setup redirect on stdin 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 }" #puts command super(command, redirects, &block) ensure tmp.close! if tmp end else super end end