Skip to content

Instantly share code, notes, and snippets.

@debility-zz
Created February 8, 2012 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debility-zz/1768177 to your computer and use it in GitHub Desktop.
Save debility-zz/1768177 to your computer and use it in GitHub Desktop.
*** cli_helper.rb 2012-02-08 20:01:17.520514397 +0900
--- cli_helper.rb.org 2012-02-08 19:49:11.137878140 +0900
***************
*** 62,79 ****
outbuf = stdout.read
errbuf = stderr.read
}
! begin
! GC.disable
! stat = Open4::popen4(cmd, &blk)
! if self.respond_to?(:logger)
! logger.debug("Exec command (pid=#{stat.pid}): #{cmd}")
! msg = "Command output:"
! msg << "\nSTDOUT:\n#{outbuf.strip}" if outbuf && outbuf.strip.size > 0
! msg << "\nSTDERR:\n#{errbuf.strip}" if errbuf && errbuf.strip.size > 0
! logger.debug(msg)
! end
! ensure
! GC.enable
end
if stat.exitstatus != opts[:expect_exitcode]
raise CommandError.new("Unexpected exit code=#{stat.exitstatus} (expected=#{opts[:expect_exitcode]})", \
--- 62,74 ----
outbuf = stdout.read
errbuf = stderr.read
}
! stat = Open4::popen4(cmd, &blk)
! if self.respond_to?(:logger)
! logger.debug("Exec command (pid=#{stat.pid}): #{cmd}")
! msg = "Command output:"
! msg << "\nSTDOUT:\n#{outbuf.strip}" if outbuf && outbuf.strip.size > 0
! msg << "\nSTDERR:\n#{errbuf.strip}" if errbuf && errbuf.strip.size > 0
! logger.debug(msg)
end
if stat.exitstatus != opts[:expect_exitcode]
raise CommandError.new("Unexpected exit code=#{stat.exitstatus} (expected=#{opts[:expect_exitcode]})", \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment