I needed to knock up a Ruby script recently that orchestrated some external processes using backticks. However something was going wrong and I need to temporarily peek into the inputs and outputs of the external programs. Ruby bend-ability to the rescue:
module Kernel
alias_method :real_backticks, :'`'
def `(cmd)
puts "`#{cmd}` => #{output = real_backticks(cmd)}"
output
end
end
No comments:
Post a Comment