File: capturing_stderr.rb

package info (click to toggle)
ruby-regexp-parser 2.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 968 kB
  • sloc: ruby: 6,396; sh: 12; makefile: 6
file content (9 lines) | stat: -rw-r--r-- 159 bytes parent folder | download
1
2
3
4
5
6
7
8
9
require 'stringio'

def capturing_stderr(&block)
  old_stderr, $stderr = $stderr, StringIO.new
  block.call
  $stderr.string
ensure
  $stderr = old_stderr
end